Natural sorting: Difference between revisions

m
added highlighting for a section name and also a computer programming language, reduce the wide of the SAMPLE INPUT section, elided the periods from an abbreviation, reduced spacing before and after "Text strings".
(Undo revision 308322 by Paddy3118 (talk) It made for more lines.)
m (added highlighting for a section name and also a computer programming language, reduce the wide of the SAMPLE INPUT section, elided the periods from an abbreviation, reduced spacing before and after "Text strings".)
Line 3:
 
{{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.
Line 28:
;Task Description
* '''Implement the first four''' of the eight given features in a natural sorting routine/function/method...
* Test each feature implemented separately with an ordered list of test strings from the &nbsp; '''Sample inputs''' &nbsp; section below, &nbsp; and make sure your naturally sorted output is in the same order as other language outputs such as &nbsp; <CODE> Python</CODE>.
* Print and display your output.
* '''For extra credit''' implement more than the first four.
Line 38:
;Sample input:
<pre>
# Ignoring leading spaces. Text strings: ['ignore leading spaces: 2-2',
'ignore leading spaces: 2-1',
'ignore leading spaces: 2+0',
'ignore leading spaces: 2+1']
 
# Ignoring multiple adjacent spaces (m.a.sMAS). Text strings: ['ignore m.a.sMAS spaces: 2-2',
'ignore m.a.sMAS spaces: 2-1',
'ignore m.a.sMAS spaces: 2+0',
'ignore m.a.sMAS 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',
'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 \xdf: 2+0',
u'Start with an s: 2+1']
</pre><br><br>