>I need to sort the ticker array while also sorting the
>corresponding hi and low data
The easiest and most useful way is to simply have different sorting options, one for alphabetical sort, one for high sort, and one for low sort. Another possible solution is to hash all of the values together and use that as the condition for swapping in the sort:
Code:
/* Very crude example */
hash1 = hash ( a[j-1].array ), hash2 = hash ( a[j].array );
if ( a[j-1].low + a[j-1].high + hash1 > a[j].low + a[j].high + hash2 ) {
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
The problem with this is that it may not sort it quite as you want, which is a reason to sort for each field instead of combining all of the fields. The output of this sort test with your given data is:
Code:
HP 23 45
AOL 40 48
CSCO 18 60
-Prelude