#4171·YOURLS

Admin list: sorting by clicks is wrong in locales that use "." as thousands separator

Author: blocoderCreated Sep 23, 2026Updated Sep 23, 2026

Code of Conduct

Submission validity

  • This is not a personal support request, that should be posted on discussions community.
  • I checked current issues and this request isn't a duplicate of an existing issue, opened or closed.

Self troubleshooting

Version

1.10.6

Description

With YOURLS_LANG set to de_DE, the admin list sorted by clicks puts links with 1,000 clicks or more in the wrong place. Example with ?sort_by=clicks&sort_order=desc:

Keyword Clicks shown
a 2
b 2
c 1.258
d 1

The SQL query sorts correctly. The client-side sort breaks it afterwards: js/tablesorte.js initialises jQuery tablesorter with the default usNumberFormat: true, while the cells contain yourls_number_format_i18n( $clicks, 0 ). In de_DE this renders 1258 as 1.258, which tablesorter reads as 1.258 and sorts between 2 and 1.

Any locale with "." as thousands separator is affected (de_DE, nl_NL, it_IT, pt_BR, ...).

Expected Behavior

Sorting by clicks orders by the actual number of clicks, independent of the locale.

A locale-independent fix in js/tablesorte.js is to extract the digits only for the clicks column:

javascript
textExtraction: {
    1: function(node, table, cellIndex){return $(node).find("small a").text();},
    4: function(node, table, cellIndex){return $(node).text().replace(/\D/g, '');}
},

Alternatively, add the raw number as data-text on the clicks cell. tablesorter reads that attribute by default.

Steps to Reproduce

  1. Set define( 'YOURLS_LANG', 'de_DE' ); and install the German translation.
  2. Have a link with 1,000 clicks or more and some links with 2 to 999 clicks.
  3. Open /admin/?sort_by=clicks&sort_order=desc, or click the "Clicks" column header.
  4. The link with 1,000+ clicks appears below the links with 2 clicks.

Context

Verified with the 1.10.6 files js/jquery-3.tablesorter.min.js (2.31.1) and js/tablesorte.js in a local test page with real rows from yourls_table_add_row(). As a workaround, a small plugin prints jQuery.tablesorter.defaults.usNumberFormat = false; on html_head, which fixes the order.