SR> I am trying to sort a struct but it needs to be sorted
SR> by AKA. It sorts the list to a degree but I end up with
SR> 1:xxx/xxx
SR> 111:xxx/xxx
SR> 2:xxx/xxx
What are you trying to use to compare? strcmp? Why not have your AKA split
up into a struct:
struct nodenum
{
int zone;
int net;
int node;
int point; /* probably 0 most of the time */
};
Then use a specialized comparison routine:
int nodenum_comp(void* l, void* r)
{
struct nodenum* nl = l;
struct nodenum* nr = r;
if (nl->zone zone)
return -1;
if (nl->zone > nr->zone)
return 1;
/* repeat above two if's for net, node, and point */
return 0;
}
If you can't (won't) split the AKA up into a struct, simply do so inside the
comparison routine. However, realize that this will take a LOT longer (since
the comp routine is called more times than there are items to sort...)
Hope this helps.
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|