Title: Numeric Sorting
Last modified: August 20, 2016

---

# Numeric Sorting

 *  Resolved [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/numeric-sorting-1/)
 * Hi Tobias,
 * Greetings for the New Year! We are still about an hour away here on the U.S. 
   East Coast, but you are well into 2013 in Germany.
 * Was the issue referred to here:
    [http://wordpress.org/support/topic/numeric-sorting](http://wordpress.org/support/topic/numeric-sorting)
 * solved as in
    [http://tablepress.org/extensions/datatables-sorting-plugins/](http://tablepress.org/extensions/datatables-sorting-plugins/)
 * I have a lot of thousand #s in my sheets that don’t sort well, e.g., 3,905,236
   sorts after 4,765.
 * I installed and activated the plugin, as mentioned, but for some reason, the 
   sorting of all of the columns got removed.
 * an example table is as attached below,
    [http://www.gurufundpicks.com/indrpt-sample-hld](http://www.gurufundpicks.com/indrpt-sample-hld)
 * I am not able to attach a reference to a table with the plugin activated, as 
   it nulls the sorting on all columns.
 * Thanks,
 * Ganaxi
 * [http://wordpress.org/extend/plugins/tablepress/](http://wordpress.org/extend/plugins/tablepress/)

Viewing 15 replies - 16 through 30 (of 34 total)

[←](https://wordpress.org/support/topic/numeric-sorting-1/?output_format=md) [1](https://wordpress.org/support/topic/numeric-sorting-1/?output_format=md)
2 [3](https://wordpress.org/support/topic/numeric-sorting-1/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/numeric-sorting-1/page/3/?output_format=md)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319611)
 * Hi,
 * ah, you are talking about the sorting plugins Extension. Right, that is only 
   loaded for TablePress tables. I’ll have to check how that can be applied to the
   WP-Table Reloaded tables as well.
    (Your link points to a site without a table
   though. Is that the correct link?)
 * About #2. I’m not talking about the column widths, but the full table width. 
   That is set to 100% by default, and that will probably have to be set to a px
   value as well.
 * Regards,
    Tobias
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319612)
 * Hi Tobias,
 * Sorry about that – that page was protected for registered users only. I have 
   disabled that now, so that you can view it. Try sorting the fifth column, as 
   the others are too narrow right now so you can’t see very well that the numeric
   sorting of strings is working well with the Extension plugin.
 * On #2, thanks for the clarification. I will try that and see.
 * Thanks,
 * Ganaxi
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319613)
 * Hi,
 * thanks for doing that. Yes, as I had assumed the Sorting Plugins Extension changes
   the sorting there.
    I will then check if this can be added to the WP-Table Reloaded
   tables as well.
 * Regards,
    Tobias
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319614)
 * Hi,
 * I think I found a possible solution.
    From what I remember, you have a custom
   plugin that loads the TablePress DataTables JS file for the WP-Table Reloaded
   tables (from [http://wordpress.org/support/topic/limits-to-tablepress/page/2](http://wordpress.org/support/topic/limits-to-tablepress/page/2))
 * It should have a line
 *     ```
       $url = plugins_url( 'js/jquery.datatables.min.js', TABLEPRESS__FILE__ );
       ```
   
 * Please try adding this line directly after that:
 *     ```
       wp_enqueue_script( 'tablepress-datatables-sorting-plugins', 'http://testgfp.wpengine.netdna-cdn.com/wp-content/plugins/tablepress-datatables-sorting-plugins/jquery.datatables.sorting-plugins.min.js', array( 'wp-table-reloaded-frontend-js' ), '1.0', true );
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319615)
 * Hi, Tobias:
 * Excellent! That worked.
 * Sie sind ein Genie!
 * Thanks again,
 * Ganaxi
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319616)
 * Hi,
 * great! Thanks for the confirmation (and for the kind words!)! 🙂
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please rate TablePress here in the plugin directory.
   Thanks!
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319620)
 * Hi, Tobias,
 * Similar to the queries above, this one I think also relates to the
    custom plugin
   that loads the TablePress DataTables JS file for the WP-Table Reloaded tables.
   As you may see from the following 2 links,
 * the first below was created using TablePress
    [http://www.gurufundpicks.com/13f-4q2-vng](http://www.gurufundpicks.com/13f-4q2-vng)
 * and it looks good!
 * However, the second one below was created using WP-Tables, and a number of functionalities
   haven’t quite transferred with that custom plugin, the two noticeable ones being:
   
   1> the sorting arrow in the header row is not visible on this one 2> the hovering
   of the rows does not highlight them
 * Any ways to fix this?
 * Thanks,
 * Ganaxi
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319621)
 * Sorry, the second one link is
    [http://www.gurufundpicks.com/13f-4q2-spr](http://www.gurufundpicks.com/13f-4q2-spr)
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319622)
 * Hi,
 * 1> The sorting arrows are not displayed because the tables that are managed in
   WP-Table Reloaded are missing a `<div>` wrapper around the table head row cells.
   TablePress adds that automatically. The best way should be to edit a WP-Table
   Reloaded PHP file. This is in general not recommended, but as WP-Table Reloaded
   won’t receive new updates, this is no problem. Please edit the file “classes/
   render.class.php” and add this
 *     ```
       if ( 0 == $row_idx && $this->output_options['first_row_th'] )
       	$cell_content = '<div>' . $cell_content . '</div>';
       ```
   
 * before the line
 *     ```
       $row_cells[] = "<{$tag}{$span_attr}{$class_attr}{$style_attr}>{$cell_content}</${tag}>";
       ```
   
 * (in line 245).
 * 2> From what I can see, the Row Hover Highlighting checkbox is not checked for
   this table in WP-Table Reloaded.
 * Regards,
    Tobias
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319623)
 * Hi, Thanks Tobias.
 * The solution to the first point worked, and you were right on the 2nd. I had 
   forgotten to check the hover highlighting on the WP-Tables.
 * Ganaxi
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319624)
 * Hi,
 * awesome! 🙂 Good to hear that this could be resolved so quickly 🙂
 * Best wishes,
    Tobias
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319627)
 * Hi, Tobias:
 * If you remember, a while ago, you helped me implement numeric sorting so that
   numbers with commas get sorted as #s and not as text strings, and you helped 
   have that implemented in WP-Tables as well (since I have a large # of Tables,
   and I had to break them down between the two due to memory limitations).
 * I seem to have recently run into a snag, and I am not able to figure out why,
   but some tables are sorting correctly, as I had mentioned to you when we corresponded
   about that, but some others (both in WP-Tables) are not (i.e., they are sorting#
   s with commas as text strings).
 * E.g,
    [https://www.gurufundpicks.com/13f-4q2-abg?s2-ssl=yes](https://www.gurufundpicks.com/13f-4q2-abg?s2-ssl=yes)
   is sorting it as a text string and [http://www.gurufundpicks.com/new-trial-page](http://www.gurufundpicks.com/new-trial-page)
   is sorting it correctly
 * Both are in TablePress, and have almost idential coding.
 * If you don’t mind, though, I am not able to unprotect the pages, and you will
   have to ‘register for free’ to access both pages.
 * Thanks,
 * Ganaxi
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319628)
 * Hi,
 * yes, I remember 🙂
 * Have you tried manually setting the data type for the columns, similar as in 
   the example at [http://tablepress.org/extensions/datatables-sorting-plugins/](http://tablepress.org/extensions/datatables-sorting-plugins/)
   but with
    “formatted-num” as the type?
 * Regards,
    Tobias
 *  Thread Starter [ganaxi](https://wordpress.org/support/users/ganaxi/)
 * (@ganaxi)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319629)
 * Hi, Tobias:
 * Thanks for your response.
 * Based on the instructions, I added
 * “aoColumnDefs”: [ { “sType”: “formatted-num”, “aTargets”: [ 3, 4, 5, 6 ] } ]
 * in the Custom Commands section of the DataTables JavaScript Features panel. However,
   that did not change anything. The table still sorts that columnn as a text string(
   FYI – the # have both $ and , i.e., like $500,500, and in other cases just the
   comma).
 * Did I interpret the instructions properly? Or perhaps is there another code to
   be added given that these are not TablePress, but WP-Tables tables? Previously,
   per your instructions, I have added the WP-Tables Reloaded Extensions plugin,
   so that the CSS and other things for WP-Tables are based on TablePress (since
   I am using both plugins due to memory issues).
 * Thanks,
 * Ganaxi
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/2/#post-3319630)
 * Hi,
 * yes, that’s what I meant. The code is the same for TablePress and WP-Table Reloaded.
   It might just be that the WP-Table Reloaded tables don’t load the Sorting Plugins.
   
   Please try this: – Deactivate the Sorting Plugins Extension. – Copy the entire
   contents of the file jquery.datatables.sorting-plugins.min.js and append it to
   the end of the file jquery.datatables.min.js in the tablepress/js/ folder.
 * That will basically load the Sorting Plugins code automatically.
 * After that, load the page again, and reload while pressing Shift+F5 (to clear
   the page from the browser cache).
 * Regards,
    Tobias

Viewing 15 replies - 16 through 30 (of 34 total)

[←](https://wordpress.org/support/topic/numeric-sorting-1/?output_format=md) [1](https://wordpress.org/support/topic/numeric-sorting-1/?output_format=md)
2 [3](https://wordpress.org/support/topic/numeric-sorting-1/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/numeric-sorting-1/page/3/?output_format=md)

The topic ‘Numeric Sorting’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 34 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/numeric-sorting-1/page/3/#post-3319634)
 * Status: resolved