Branch: Tag:

2001-08-28

2001-08-28 14:33:26 by Honza Petrous <hop@unibase.cz>

Added oid_sort_func. Usable for sorting oid values. Ex: "1.2.1" before "1.11.1"

Rev: lib/modules/Array.pmod:1.58

597:    if(arrayp(x)) return x;    return ({ x });   } +  +  + //! Sort with care of numerical sort for OID values: + //! "1.2.1" before "1.11.1" + int oid_sort_func(string a0,string b0) + { +  string a2="",b2=""; +  int a1, b1; +  sscanf(a0,"%d.%s",a1,a2); +  sscanf(b0,"%d.%s",b1,b2); +  if (a1>b1) return 1; +  if (a1<b1) return 0; +  if (a2==b2) return 0; +  return oid_sort_func(a2,b2); + }