Support » Plugins and Hacks » [Resolved] Second Sorting Criteria

[Resolved] Second Sorting Criteria

  • Me again,

    it is still working fine, no worries.

    But can I add a second criteria to sort my rows? So for example (I am dealing with sport standings) when two teams have the same amount of points, that the second criteria would be the goal difference. Is that possible?

    Thanks heaps and regards from Sydney


Viewing 10 replies - 1 through 10 (of 10 total)
  • EDIT: My used code at the moment is:
    [table id=wes filter="blackhawks||avalanche||dallas stars||minnesota wild||nashville predators||st. louis blues||winnipeg jets" hide_columns="1" row_order="sort" row_order_sort_column="J" row_order_sort_direction="DESC"/][/tab]


    Maybe you could achieve this by using aDataSort command.

    Let’s assume that your score column is the 1st column, and goal column is the 2nd, then the multicolumn sort aDataSort command is like the following:

    "aoColumnDefs": [
          { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] }

    Just add this command to cusome command field in “Feature of DataTables JavaScript Library” section when editting the table in TablePress admin page.

    Please confirm by replying whether this works for you.


    And further, if you also want a combination sort for it when clicking on the 2nd column head, the custom command should be changed to:

    "aoColumnDefs": [
          { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] },
          { "aDataSort": [ 1, 0 ], "aTargets": [ 1 ] }


    sounds difficult. Where should I enter the code?? Because I am not talking about a table. As you can see in my above post I use a code, to exclude certain teams of my large table.

    For example: Eastern Conference hosts 16 teams, just 8 of them should be displayed in my table. Everything worked fine, I got that table. And the table is sorted by points, perfect. But know: Where to put the code? In my above posted code?

    But thank you for your help so far.

    EDIT: First sorting priority: Points (10th column)
    Second sorting priority: Goals difference (9th column)

    Well then, the command should change to:

    "aoColumnDefs": [
          { "aDataSort": [ 9, 8 ], "aTargets": [ 9 ] },
          { "aDataSort": [ 9, 8 ], "aTargets": [ 8 ] }

    In your WP Dashboard, navigate to TablePress, then choose to Edit this particular table. At the edit screen, scrolling down to section with title “Feature of DataTables JavaScript Library”, there should be a line of text
    field at the last line in this section. Just put the code into it and save.

    Then go to view your page to see if this is what you expect.

    Okay! Unfortunately it doesnt work 🙁

    But thanks 🙂

    Sorry for that. Please wait for the author to solve it.

    Plugin Author TobiasBg



    thanks for your post, and sorry for the trouble.

    Unfortunately, the Table Row Order Extension can only use one sort criterion, so the only chance here is to use the JS based sorting.

    Instead of the aDataSort parameter, we’ll however need the aaSorting, which defines the initial sort that shall be performed.
    Also, the numbers in the JS code (for the columns) only take into account the visible columns on the page, and as one column is hidden in the table, the 8 and 9 become 7 and 8 (but in reversed order, so that PTS is sorted on first). So, please try this “Custom Command”:

    "aaSorting": [[8,'desc'], [7,'desc']]


    You made it! Awesome.

    Thanks mate!

    Plugin Author TobiasBg



    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Second Sorting Criteria’ is closed to new replies.