Talk:Natural sorting: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 27: Line 27:


Oh; and this is the first time I think, that I have tried to save space by linking the task test-suite in this way - what do you think?<br>--[[User:Paddy3118|Paddy3118]] 06:27, 27 April 2011 (UTC)
Oh; and this is the first time I think, that I have tried to save space by linking the task test-suite in this way - what do you think?<br>--[[User:Paddy3118|Paddy3118]] 06:27, 27 April 2011 (UTC)

:For me: It involves aspects of unicode where I do not have complete knowledge nor do I know how to get complete knowledge (this seems to apply for orderings 2 3 6 7 8 and maybe 4), so I am waiting until I am inspired to try to discover these structures in unicode, or for someone else to pick it up. --[[User:Rdm|Rdm]] 14:43, 27 April 2011 (UTC)

Revision as of 14:43, 27 April 2011

Why draft?

I'm never sure about Unicode, and this is my first "choose any four from eight" type task description.

I think I will change it to ask that at least the first four are done then leave the others as "extra credit" - that way language examples will be more comparable. --Paddy3118 11:16, 23 April 2011 (UTC)

Note that, unless constrained by their language, a good programmer will implement this as a sort routine that takes a text normalization function, and after the first two examples this task devolves down to writing the normalization function and testing it. (Some languages provide a sort routine which performs suboptimally with this approach but I think we can neglect that issue here.) --Rdm 12:10, 23 April 2011 (UTC)
Like function sortkeygen of the python example ;-)
--Paddy3118 12:20, 23 April 2011 (UTC)

Numeric sub-fields

For the fourth one (numeric sub-fields), are we to ignore the non-numeric parts or to assume they're the same? –Donal Fellows 17:28, 23 April 2011 (UTC)

No field is ignored Donal.

  1. Split the string into fields of alternating numeric/non-numeric runs of characters (or non-numeric/numeric).
  2. when comparing two strings s1 and s2 say, now split as fields, start from the rightmost fields and compare them - if the first fields are numeric then compare them as integers; if the fields are both non-numeric then compare them as character strings; if they differ in type then assume any integer field is always less than any non-integer field (the two strings shouldn't really be compared, but this gives them a defined order).
  3. If the two rightmost fields are equal then compare the next two fields, and so on.
  4. If the fields of the two strings compare equal so far, but one string has no more fields but the other has more fields, then the string with least fields is the smaller.

Using the above comparison rules you should be able to sort/order strings. --Paddy3118 19:11, 23 April 2011 (UTC)

Cool. That corresponds to one of Tcl's built-in sorting modes. :-) –Donal Fellows 20:01, 23 April 2011 (UTC)
Wait! I'm gobsmacked! Do you have a link to the documentation? --Paddy3118 21:25, 23 April 2011 (UTC)

Criticisms please

I note that it has been several days without another language implementation added to the initial Python so I would like to stick my chin out, (figuratively), and ask for criticisms.

Is the task too long? Does it seem like too much work? Is it hard to understand? ...

Oh; and this is the first time I think, that I have tried to save space by linking the task test-suite in this way - what do you think?
--Paddy3118 06:27, 27 April 2011 (UTC)

For me: It involves aspects of unicode where I do not have complete knowledge nor do I know how to get complete knowledge (this seems to apply for orderings 2 3 6 7 8 and maybe 4), so I am waiting until I am inspired to try to discover these structures in unicode, or for someone else to pick it up. --Rdm 14:43, 27 April 2011 (UTC)