* Sort collected valuables, most frequent to least. We could just * as easily use qsort, but we don't care about efficiency here. */
| 795 | * as easily use qsort, but we don't care about efficiency here. |
| 796 | */ |
| 797 | staticfn void |
| 798 | sort_valuables( |
| 799 | struct valuable_data list[], |
| 800 | int size) /* max value is less than 20 */ |
| 801 | { |
| 802 | int i, j; |
| 803 | struct valuable_data ltmp; |
| 804 | |
| 805 | /* move greater quantities to the front of the list */ |
| 806 | for (i = 1; i < size; i++) { |
| 807 | if (list[i].count == 0) |
| 808 | continue; /* empty slot */ |
| 809 | ltmp = list[i]; /* structure copy */ |
| 810 | for (j = i; j > 0; --j) { |
| 811 | if (list[j - 1].count >= ltmp.count) |
| 812 | break; |
| 813 | list[j] = list[j - 1]; |
| 814 | } |
| 815 | list[j] = ltmp; |
| 816 | } |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | #if 0 |
| 821 | /* |