Jump to content

Topic on Extension talk:Arrays/archive 2

{{#arraysort:}} does not honour proper numerical sorting

1
Slgrandson (talkcontribs)

It seems that {{#arraysort:}} is more effective when letters are involved, but its duties with numbers leave a bit to be desired--and the extension's documentation has never made note of that. That much I found out after noon two days ago after setting up my first box-office chart for my geofictional realm in 8½ years. A title that was supposed to be #18 in rank...suddenly jumps into fourth place. (For context, the figures are 645247 [#3], 44189 [#4], 422290 [#5], 400261 [#6]... when they should be arranged as 645247, 422290, 400261...44189.)

It seems that PHP's natsort may be needed to remedy this in a future update of the extension. Until then, one must resort to this workaround if their site uses Page Forms (ad hoc example provided below):

{{#arraydefine:rand|{{#arraymap:4, 586, 46, 8, 79, 1031|,|*|<span style="display: none">{{padleft:*|4|0}}</span>*}}}}{{#arraysort:rand|desc}}{{#arrayprint:rand}}

To developers @Lidingpku: /@Baojie: /@Danwe: (And maybe recent talk-page guest @MGChecker: ) Just letting you three know of this apparent, hitherto-undiscovered upstream bug (in case you're still active on Wikimedia/MW.org). (Which may be enough for me to finally join WM Phabricator just so I can make a filing on this matter.)


Delayed by two days thanks to the technical difficulties described in Support desk Topic:Xjjrg9rs06eshjj0. --Slgrandson (talk) 22:18, 8 June 2023 (UTC)

Reply to "{{#arraysort:}} does not honour proper numerical sorting"