Release Date: 1 February 2008
Namedt_mer_sort - initiate a sort
Generic Prototypedt_mer_sort(dt_Handle, dt_Handle, dt_Integer, dt_Integer, dt_Integer)
C Prototype#include "dt_merlin.h"
dt_Integer dt_mer_sort(dt_Handle hitlist, dt_Handle column, dt_Integer sortmethod, dt_Integer direction, dt_Integer *status)
FORTRAN Prototypeinclude 'dt_f_merlin.inc'
integer*4 dt_f_mer_sort(hitlist, column, sortmethod, direction, status)
DescriptionBegins a sort task on the server. The rows currently in the hitlist are sorted using the cells from the column 'column'. The data are sorted in ascending or descending order depending on the value of 'direction', which can be DX_SORT_ASCENDING or DX_SORT_DESCENDING.
Several sort methods may be used by the Merlin server, but they all share the following two characteristics:
- Sorting is stable. That is, the relative ordering of two cells will not change if the values of the cells are equal.The type of sort to be performed is controlled by the value of 'sortmethod', which may take the following values:
Performs a straight ASCII sort.DX_SORT_ANC
ASCII sort, no case. Equivalent to the conversion of all characters to upper case, followed by an ASCII sort.DX_SORT_ANW
ASCII sort, no whitespace. Equivalent to removal of tab, space, <CR>, <NL> followed by an ASCII sort.DX_SORT_ANP
ASCII sort, no punctuation. Equivalent to removal of all characters not in the set of [A-Za-z0-9], followed by an ASCII sort.DX_SORT_ANCP
Combination of no case, no punctuation sort.DX_SORT_ANCW
Combination of no case, no whitespace sort.DX_SORT_ANPW
Combination of no punctuation, no whitespace sort.DX_SORT_ANCPW
Combination of no case, punctuation or whitespace sort.DX_SORT_AAZ
ASCII sort of characters only. Equivalent to removal of all characters not in the set of [A-Za-z] followed by a no-case ASCII sort.DX_SORT_NUM
Sort numerically by absolute value. Ignores sign of the numbers.DX_SORT_CAS
Sort CAS numbers.DX_SORT_MFM
Sort by molecular formula. Considers each element/number combination as a single token in the comparison.DX_SORT_LEN
Sort by length. Short strings are lower than long strings.
Return ValueThe status of the sort task is returned in 'status' (see dt_continue(3) for descriptions). If the hitlist is short enough that time-slicing is not required, the value of 'status' will be DX_STATUS_DONE. Otherwise, the status will be DX_STATUS_IN_PROGRESS and dt_continue(3) will be required to finish the task.
The functions return value is either the progress on the task (see dt_done_when(3)) or -2 if an error is encountered.
Related Topicsdt_abort(3) dt_continue(3) dt_done_when(3) dt_mer_nsorts(3)