abdullah768 / Codeforces Contest Problem Sorter

// ==UserScript==
// @name         Codeforces Contest Problem Sorter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  A script that allows sorting problems based on the number of submissions
// @author       Abdullah Aslam
// @match        codeforces.com/contest/*
// @match        codeforces.com/gym/*
// @license MIT
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  $(document).ready(function () {

    var $table = $('table.problems').first();
    var $rows = $('tbody > tr', $table);
    $rows.sort(function (a, b) {
      var keyA = parseInt($('.right a', a).text().substring(2));
      var keyB = parseInt($('.right a', b).text().substring(2));
      return (keyA > keyB) ? -1 : 1;
    });
    $.each($rows, function (index, row) {
      $table.append(row);
    });

  });
})();