This is an archive copy of the IUCr web site dating from 2008. For current content please visit https://www.iucr.org.
[IUCr Home Page] [CIF Home Page] [mmCIF Home Page]

Re: Sorting order.

herbert_bernstein (yaya@aip.org)
Fri, 12 Jul 96 09:22:28 EDT


Perhaps there is a need for some additional sub-types of the
character data type to clarify sort order preferences, but the
forcing of quotes or leading 0's seems, somehow inelegant.  As
a short-term kludge, may I suggest using a hybrid sort paradigm,
which recognizes character stings which appear numeric, and
sorts them all in numeric order (as if they had been presented
right justified) before all alphabetic strings.

--- Forwarded mail from mmciflist@ndbdev.rutgers.edu

>From mmciflist@ndbdev.rutgers.edu Fri Jul 12 09:13:54 1996
Date: Fri, 12 Jul 1996 09:13:50 -0400
>From: Peter Keller <bsspak@bath.ac.uk>
To: yaya@aip.org
Subject: Sorting order.

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)
========================================================================



--- End of forwarded message from mmciflist@ndbdev.rutgers.edu