Title: Row Sorting Based on Defined Text/Numbers
Last modified: November 24, 2018

---

# Row Sorting Based on Defined Text/Numbers

 *  Resolved [amanfre](https://wordpress.org/support/users/amanfre/)
 * (@amanfre)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/)
 * Hi,
 * When a user first comes to my site, I want rows to be sorted automatically based
   on text included in columns 7 & 8.
 * I thought the best way here would be to include row sorting, however how can 
   you do this based on setting a defined order. For example, I want rows to be 
   sorted in this order:
 * Live
    In XX days Ended
 * Im aware of the other method in creating a hidden column and setting a number
   value to then sort this way, however the issue is that the text in columns 7 &
   8 are not fixed and include shortcode for a countdown timer. So text will effectively
   change upon a certain date being met or expired, hence the live, days then ended
   words above.
 * How can this be done?
 * Site is [http://www.stoblock.io](http://www.stoblock.io)
 * Thanks
    Anthony

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/#post-10913463)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Unfortunately, I don’t know a solution to this. The standard algorithm can’t 
   really know that you don’t want alphabetic sorting, but a custom order. If the
   approach of using an extra hidden column won’t work, your only chance is to develop
   a custom sorting algorithm that can interpret your values and assign a sortable
   value to them.
    For inspiration, you could check the source of the TablePress
   Extension from [https://tablepress.org/extensions/datatables-sorting-plugins/](https://tablepress.org/extensions/datatables-sorting-plugins/)
   and the DataTables documentation at [https://datatables.net/plug-ins/sorting/](https://datatables.net/plug-ins/sorting/)
 * Regards,
    Tobias
 *  Thread Starter [amanfre](https://wordpress.org/support/users/amanfre/)
 * (@amanfre)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/#post-10914150)
 * Thanks for the quick response Tobias.
 * I think it may be easier to take a different route.
 * I just noticed when I clicked on the sorting arrows for column F (sale 1), the
   descending arrow gives me the order that I want, being Live, In XX Days then 
   Ended.
 * How can I set this up to occur automatically everytime I go to the page without
   hitting the sorting arrow.
 * Cheers
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/#post-10916453)
 * Hi,
 * for that, add this to the “Custom Commands” text field on the table’s “Edit” 
   screen:
 *     ```
       "order": [ [ 5, "desc" ] ]
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [amanfre](https://wordpress.org/support/users/amanfre/)
 * (@amanfre)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/#post-10916494)
 * Perfect, worked. Much appreciated.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/#post-10916621)
 * 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/#new-post)
   here in the plugin directory. Thanks!

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

 The topic ‘Row Sorting Based on Defined Text/Numbers’ 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/)

 * 5 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/row-sorting-based-on-defined-text-numbers/#post-10916621)
 * Status: resolved