Branch: Tag:

1996-06-09

1996-06-09 14:39:19 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

added functions for sorting alphabetically

Rev: src/array.c:1.12
Rev: src/array.h:1.8

542:    return a->subtype - b->subtype;       case T_INT: -  return a->u.integer - b->u.integer; +  if(a->u.integer < b->u.integer) return -1; +  if(a->u.integer > b->u.integer) return 1; +  return 0;       default:    if(a->u.refs < b->u.refs) return -1;
557:    switch(a->type)    {    case T_INT: -  return a->u.integer - b->u.integer; +  if(a->u.integer < b->u.integer) return -1; +  if(a->u.integer > b->u.integer) return 1; +  return 0;       case T_FLOAT:    if(a->u.float_number < b->u.float_number) return -1;
572:    }   }    + static int alpha_svalue_cmpfun(struct svalue *a, struct svalue *b) + { +  if(a->type != b->type) return a->type - b->type; +  switch(a->type) +  { +  case T_INT: +  if(a->u.integer < b->u.integer) return -1; +  if(a->u.integer > b->u.integer) return 1; +  return 0; +  +  case T_FLOAT: +  if(a->u.float_number < b->u.float_number) return -1; +  if(a->u.float_number > b->u.float_number) return 1; +  return 0; +  +  case T_STRING: +  return my_strcmp(a->u.string, b->u.string); +  +  case T_ARRAY: +  if(a==b) return 0; +  if(!a->u.array->size) return -1; +  if(!b->u.array->size) return 1; +  return alpha_svalue_cmpfun(ITEM(a->u.array), ITEM(b->u.array)); +  +  default: +  return set_svalue_cmpfun(a,b); +  } + } +    /*    * return an 'order' suitable for making mappings, lists other sets    */
589:   }       + /* +  * return an 'order' suitable for sorting. +  */ + INT32 *get_alpha_order(struct array *a) + { +  return get_order(a, alpha_svalue_cmpfun); + } +  +    static INT32 low_lookup(struct array *v,    struct svalue *s,    cmpfun fun)