Natural sorting: Difference between revisions
Content deleted Content added
m added whitespace so that the "sample input" in the task's preamble displays at full width. |
corrected some misspellings, added whitespace, changed horizontal lists to vertical list so as to not have a scroll bar for the sample inputs, aligned sample input text strings, insured that the sample inputs fit on one screen page.. |
||
Line 1:
{{task|Sorting Algorithms}}▼
[[Category:Sorting]]
{{Sorting Algorithm}}
▲{{task|Sorting Algorithms}}
Natural sorting is the sorting of text that does more than rely on the
order of individual characters codes to make the finding of
individual strings easier for a ''human'' reader.
There is no "one true way" to do this, but for the purpose of this task 'natural' orderings might include:
Line 22 ⟶ 21:
:7. Sort ligatures as separate letters.
:8. Replacements:
:: Sort
:: Sort ſ, LATIN SMALL LETTER LONG S as s
:: Sort ʒ, LATIN SMALL LETTER EZH as s
:: <big><big> ∙∙∙ </big></big>
;Task Description
Line 32 ⟶ 30:
* Test each feature implemented separately with an ordered list of test strings from the 'Sample inputs' section below, and make sure your naturally sorted output is in the same order as other language outputs such as Python.
* Print and display your output.
* '''For extra credit''' implement more than the first four.
Note:
;Sample input:
<pre>
# Ignoring leading spaces. Text strings: ['ignore leading spaces: 2-2',
'ignore leading spaces: 2-1',
'ignore leading spaces: 2+1']
# Ignoring multiple adjacent spaces (m.a.s)▼
▲# Ignoring multiple adjacent spaces (m.a.s). Text strings: ['ignore m.a.s spaces: 2-2',
'ignore m.a.s spaces: 2-1',
'ignore m.a.s spaces: 2+0',
'ignore m.a.s spaces: 2+1']
# Equivalent whitespace characters. Text strings: ['Equiv. spaces: 3-3',
'Equiv. \rspaces: 3-2',
'Equiv. \x0cspaces: 3-1',
'Equiv. \x0bspaces: 3+0',
'Equiv. \nspaces: 3+1',
'Equiv. \tspaces: 3+2']
# Case Independent sort. Text strings: ['cASE INDEPENDENT: 3-2',
'caSE INDEPENDENT: 3-1',
'casE INDEPENDENT: 3+0',
'case INDEPENDENT: 3+1']
# Numeric fields as numerics. Text strings: ['foo100bar99baz0.txt',
'foo100bar10baz0.txt',
'foo1000bar99baz10.txt',
'foo1000bar99baz9.txt']
# Title sorts. Text strings: ['The Wind in the Willows',
# Equivalent accented characters (and case)▼
'The 40th step more',
'The 39 steps',
'Wanda']
▲# Equivalent accented characters (and case). Text strings: [u'Equiv. \xfd accents: 2-2',
u'Equiv. \xdd accents: 2-1',
u'Equiv. y accents: 2+0',
u'Equiv. Y accents: 2+1']
# Separated ligatures. Text strings: [u'\u0132 ligatured ij',
'no ligature']
# Character replacements. Text strings: [u'Start with an \u0292: 2-2',
u'Start with an \u017f: 2-1',
u'Start with an s: 2+1']
</pre><br><br>
=={{header|AppleScript}}==
|