Title: Table will not sort sequentially
Last modified: January 22, 2018

---

# Table will not sort sequentially

 *  Resolved [cbottorff89](https://wordpress.org/support/users/cbottorff89/)
 * (@cbottorff89)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/)
 * Hello!
 * I’m trying to set up a table ranking the best state for female entrepreneurs.
   I am using DataTables to enable sorting of columns, and by default everything
   is sorted with the first column numbered 1-50. However, if I sort by another 
   column and then try to get the first column to sort 1-50 again, it doesn’t work
   properly. Instead of going 1, 2, 3… it sorts by 1, 10, 11, 12, 13… until it finishes
   the teens and then hits 2, 20, 21, 22… and so forth.
 * I found this bit of code on another thread saying I could tweak it in the “Custom
   Commands” field, but I’m unsure of how to do so to make the table do what I want:“
   columnDefs”: [ { “type”: “formatted-num”, “targets”: [ 0 ] } ]
 * Other tables work properly if I have the number separated out into its own column(
   as seen on [https://fitsmallbusiness.com/best-states-to-start-a-business/](https://fitsmallbusiness.com/best-states-to-start-a-business/))
   but I would really love to not have to do that. Can you please lend a hand?
 * Thanks in advance!!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ftable-will-not-sort-sequentially%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9892610)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * The cause for that simply is that the first column is more than just plain numbers.
   The sorting algorithm therefore can’t know how to treat this.
 * The “Custom Command” that you found is the perfect solution though, and I recommend
   that you use that. To make it work, you will however first have to download, 
   install, and activate the TablePress Extension from [https://tablepress.org/extensions/datatables-sorting-plugins/](https://tablepress.org/extensions/datatables-sorting-plugins/)
 * Regards,
    Tobias
 *  Thread Starter [cbottorff89](https://wordpress.org/support/users/cbottorff89/)
 * (@cbottorff89)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9894249)
 * Hi Tobias,
 * We do have the extension, I just don’t know how to adjust the code.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9895279)
 * Hi,
 * the command that you mentioned above is correct. Just add
 *     ```
       "columnDefs": [ { "type": "formatted-num", "targets": [ 0 ] } ]
       ```
   
 * to the “Custom Commands” textfield on the table’s “Edit” screen.
 * Regards,
    Tobias
 *  Thread Starter [cbottorff89](https://wordpress.org/support/users/cbottorff89/)
 * (@cbottorff89)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9895308)
 * Hi Tobias,
 * The code is in that field but doesn’t work; that’s why I thought I needed to 
   adjust it. Any other ideas?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9895360)
 * Hi,
 * when I check the source code of the page [https://fitsmallbusiness.com/best-states-for-women-entrepreneurs/](https://fitsmallbusiness.com/best-states-for-women-entrepreneurs/),
   I don’t see the code added there. Also, I don’t see that the Extension’s JS file
   is loaded. Are you sure that you added it to the “Custom Commands” field of the
   table that is shown on that page?
    Did you clear the cache?
 * Regards,
    Tobias
 *  Thread Starter [cbottorff89](https://wordpress.org/support/users/cbottorff89/)
 * (@cbottorff89)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9897936)
 * Hi Tobias,
 * I wish I could upload a screenshot but yes I’m fairly sure I put it in the right
   location. At the bottom of the page is a box that says “Features of the DataTables
   JavaScript Library.” The “Use DataTables” box is checked and so is the one for“
   Sorting.” Then I put the code in the “Custom Commands” field at the bottom.
 * I tried clearing the cache and a different browser but it still doesn’t list 
   items sequentially. How would I check if a JS file is loaded (does that mean 
   JavaScript)?
 * (I apologize, you’re speaking to someone with very little coding experience.)
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9900883)
 * Hi,
 * indeed, now I can see the “Custom Command” in the page’s source code.
    I don’t
   see the necessary JS file though. Are you sure that you downloaded and installed
   the TablePress Extension from [https://tablepress.org/extensions/datatables-sorting-plugins/](https://tablepress.org/extensions/datatables-sorting-plugins/)
   as a new WordPress plugin?
 * Regards,
    Tobias
 *  Thread Starter [cbottorff89](https://wordpress.org/support/users/cbottorff89/)
 * (@cbottorff89)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9904257)
 * Hey there,
 * The plugins on our site are managed by another department, so I’ve sent them 
   a link to this conversation and will let them investigate. Thanks.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9904701)
 * Hi,
 * sounds good! Without this plugin, the code above will not work.
 * Regards,
    Tobias
 *  Thread Starter [cbottorff89](https://wordpress.org/support/users/cbottorff89/)
 * (@cbottorff89)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9923568)
 * I think we’ve finally got this sorted out. Thank you for the assist!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9923717)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](https://wordpress.org/support/plugin/tablepress/reviews/)
   here in the plugin directory. Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Table will not sort sequentially’ 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/)

## Tags

 * [Numbers](https://wordpress.org/support/topic-tag/numbers/)
 * [sorting](https://wordpress.org/support/topic-tag/sorting/)

 * 11 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/table-will-not-sort-sequentially/#post-9923717)
 * Status: resolved