Sorting and spaces.

Tobiah toby at tobiah.org
Thu May 31 10:18:11 EDT 2018


I had a case today where I needed to sort two string:

	['Awards', 'Award Winners']

I consulted a few sources to get a suggestion as to
what would be correct.  My first idea was to throw them
through a Linux command line sort:

	Awards
	Award Winners

Then I did some Googling, and found that most US systems seem
to prefer that one ignore spaces when alphabetizing.  The sort
program seemed to agree.

I put the items into the database that way, but I had forgotten
that my applications used python to sort them anyway.  The result
was different:

	>>> a = ['Awards', 'Award Winners']
	>>> sorted(a)
	['Award Winners', 'Awards']

So python evaluated the space as a lower ASCII value.

Thoughts?  Are there separate tools for alphabetizing
rather then sorting?


Thanks,


Tobiah



More information about the Python-list mailing list