Octal number problem

Tim Evans t.evans at paradise.net.nz
Sat Feb 22 04:44:41 CET 2003


Gary Duncan <gmduncan at netspace.net.au> writes:

[snip]
> 	I have a list of 5-digit decimal numbers, which was constructed
> with leading zeroes where necessary so that the list is sorted by magnitude
> using Unix 'sort' (otherwise '00200' would appear before '1').

Slightly off-topic, but (at least when using gnu sort) 'sort -n' can
fix that:

$ printf '100\n2' | sort
100
2
$ printf '100\n2' | sort -n
2
100

The '-n' switch sorts the lines as decimal numbers.

-- 
Tim Evans




More information about the Python-list mailing list