Type of callback function used to compare two items of the sorted data according to the specified criterium.

A special pseudofunction called AUTOARRANGE indicates that sorted data is autoarrangeable. AUTOARRANGE is defined as ((SORTFUNC *)1).

typedef int SORTFUNC(const t_sorthdr *sh1,const t_sorthdr *sh2,const int sort);


(In) Pointer to the first data item
(In) Pointer to the second data item
(In) Sorting criterium. This is the zero-based index of the column on the screen

Return values:

This function should return -1 if item pointed to by sh1 is "less" than sh2, +1 if sh1 is "larger" and 0 if sh1 and sh2 are "equal"


This is the original code of the sorting function used by the module table:

int Modulesortfunc(const t_sorthdr *sh1,const t_sorthdr *sh2,const int sort) {
  int i=0;
  ulong t1,t2;
  t_module *mod1,*mod2;
  mod1=(t_module *)sh1;
  mod2=(t_module *)sh2;
  if (
sort==1) {                       // Sort by module size, largest first
    if (mod1->size>mod2->size) i=-1;
    else if (mod1->size<mod2->size) i=1; }
  else if (
sort==2) {                  // Sort by address of entry point
    if (mod1->entry<mod2->entry) i=-1;
    else if (mod1->entry>mod2->entry) i=1; }
  else if (
sort==3)                    // Sort by short module name
  else if (
sort==4) {                  // Sort by module type
    t1=mod1->type & (MOD_NETAPP|MOD_HIDDEN);
    t2=mod2->type & (MOD_NETAPP|MOD_HIDDEN);
    if (t1>t2) i=-1;
    else if (t1<t2) i=1; }
  else if (
sort==6)                    // Sort by full path
  if (i==0) {                          // Additionally sort by base address
    if (mod1->base<mod2->base) i=-1;
    else if (mod1->base>mod2->base) i=1; };
  return i;

See also:

Sorted data, table, t_sorthdr, Createsorteddata(), Sortsorteddata()