Title: Sorting html  link text
Last modified: August 20, 2016

---

# Sorting html link text

 *  Resolved [sedohr7682](https://wordpress.org/support/users/sedohr7682/)
 * (@sedohr7682)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sorting-html-link-text/)
 * I use 2 or 3 character html link text in one of my cells. The character represent
   numeric data (price).
 * [http://smoothiemakershq.com/compare-smoothie-makers/](http://smoothiemakershq.com/compare-smoothie-makers/)
 * The column will sort on the 1st char of the 2 character ‘value’ and therefore
   the column does not sort correctly. At first I thought it was because the cell
   has text and therefore is being sorted as a string rather than a numeric.
 * However, I have a similar table running on another site that sorts the same type
   of data correctly. The only difference is this table has the same # of characters
   for each ‘price’.
    [http://dysonvacuumreviewdude.com/compare-dyson-models/](http://dysonvacuumreviewdude.com/compare-dyson-models/)
 * Does TablePress know a cell contains an html link and therefore sorts based ONLY
   on the link text? If so, is the data still considered a string for sorting purposes?
   That’s the only thing I can figure out is happening here.
 * [http://wordpress.org/extend/plugins/tablepress/](http://wordpress.org/extend/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sorting-html-link-text/#post-3574522)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * You are right. The DataTables JavaScript library does recognize that there’s 
   HTML code in the cell, and then just sorts with the link text. However, it treats
   that as a string and not a number. That leads to to result that you are seeing.
   
   To fix this, please install and activate the TablePress Extension from [http://tablepress.org/extensions/datatables-numhtml/](http://tablepress.org/extensions/datatables-numhtml/)
   After that, add this to the “Custom Commands” text field in the “Features of 
   the DataTables JavaScript library” section on the “Edit” screen of the table 
   from [http://smoothiemakershq.com/compare-smoothie-makers/](http://smoothiemakershq.com/compare-smoothie-makers/):
 *     ```
       "aoColumnDefs": [ { "sType": "num-html", "aTargets": [ 2 ] } ]
       ```
   
 * This will fix the data type for the third column of the table (there’s a 2 in
   the code, because counting starts with 0).
 * Regards,
    Tobias
 *  Thread Starter [sedohr7682](https://wordpress.org/support/users/sedohr7682/)
 * (@sedohr7682)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sorting-html-link-text/#post-3574541)
 * Perfect! Thanks Tobias…..
 * Just FYI… wanted to give a small token of appreciation (in between jobs right
   now but your plugin/support is AWESOME!)but can’t send gift card w/o and email
   addy.
 * Could not find it anywhere on your donate or amazon wishlist (US) page. ;o(
 * Didn’t want to donate via PP and have them remove fees.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/sorting-html-link-text/#post-3574548)
 * Hi,
 * great to hear that this solved it 🙂
 * And thanks for wanting to donate, I really appreciate it! 🙂
    For that gift card,
   please send me an email to the address that you can see on [http://tablepress.org/imprint/](http://tablepress.org/imprint/)
   I will then send you the email address that I prefer for Amazon (because it is
   a different one). Thanks!
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](http://wordpress.org/support/view/plugin-reviews/tablepress)
   here in the plugin directory. Thanks!

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

The topic ‘Sorting html link text’ 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

 * [anchor text](https://wordpress.org/support/topic-tag/anchor-text/)
 * [html links](https://wordpress.org/support/topic-tag/html-links/)
 * [link text](https://wordpress.org/support/topic-tag/link-text/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

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