Each method uses its own comparator to determine if two items are in the right order. Then it reverse
bubble sorts the entire list until there are no changes or 64 somethings
? happened.
For the following pseudo-code, if the return value is positive then the items are swapped. Since it's reverse, it's starting with the last item. Item1 starts at 319 and item2 starts at 318.
Field -
If Item1 can be used in the field then
If Item2 can be used in the field then
return 0 //If both are usable then ignore them
Else
return 1 //Item2 can't be used in the field, Item1 should be higher than that.
End If
Elseif Item2 can be used in the field then
return -1 //Item1 can't be used in the field, but item2 is already higher
Else
return 0 //Neither can be used in the field and it doesn't care what the order is now.
End If
Battle -
(Same as above, but replace "can be used in field" with "can be used in battle")
Throw -
(Same as above, but replace same condition with "can be thrown")
Type -
return Item2.index - Item1.index //If Item1's index is less than Item2's the result will be positive and trigger a swap
Name -
If ItemNameSortOrder[ Item1.index ] < ItemNameSortOrder [Item2.index] then //ItemNameSortOrder is a fixed array with ranked positions in a full item list.
return 1
End If
Most -
return Item1.count - Item2.count
Least -
return Item2.count - Item1.count