Sorting order.
Peter Keller (bsspak@bath.ac.uk)
Thu, 11 Jul 1996 12:12:04 +0100 (BST)
Hi everyone,
I'm starting to play around with sorting/searching, but I have hit the
classical problem of sorting as strings vs. sorting as numbers. For
example, compared as numbers, 2 < 10, but compared as strings,
'10' < '2' .
This is a problem where CIF items are defined in the dictionary as
character types, but in practice, people tend to convert them from
numbers. _atom_site.id is a case in point: its
_item_type_list.primitive_code is 'char', so based purely on information
in the dictionary, a sort would have to use character, rather than
numerical sorting.
I would like to suggest, that when numbers are output as the contents of
such data items, they should be output right-justified in a fixed-width
field, and either quoted ( ' 2' < ' 10' ), or padded with zeros
( 00002 < 00010 ), which solves the problem.
Regards,
Peter.
========================================================================
Peter Keller. \
Dept. of Biology and \ "...nothing works, but
Biochemistry, \ everything survives...."
University of Bath, \
Bath, BA2 7AY, UK. \ --- Carlos Fuentes
------------------------------\-----------------------------------------
Tel. (+44/0)1225 826826 x 4302 | Email: P.A.Keller@bath.ac.uk (Internet)
Fax. (+44/0)1225 826449 | P.A.Keller%bath.ac.uk@UKACRL (BITNET)
========================================================================