Item Sorting

  • Thread starter Thread starter Sega Chief
  • Start date Start date
Status
Not open for further replies.
S

Sega Chief

Guest
Hey all,

I had a question about how items are sorted through the inventory using the different categories. I've always used Type as it sorts by their actual item index, but a few people have been asking about the others like sorting for Battle (damage dealing items I imagine) and finding it to be a bit all over the place. Is there a way to change the way these sort categories behave? Or is there info on how they sort items anywhere?
 
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 -
Code: [Select]
Code:
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 IfElseif Item2 can be used in the field then   return -1 //Item1 can't be used in the field, but item2 is already higherElse   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 -
Code: [Select]
Code:
return Item2.index - Item1.index //If Item1's index is less than Item2's the result will be positive and trigger a swap
Name -
Code: [Select]
Code:
If ItemNameSortOrder[ Item1.index ] < ItemNameSortOrder [Item2.index] then //ItemNameSortOrder is a fixed array with ranked positions in a full item list.   return 1End If
Most -
Code: [Select]
Code:
return Item1.count - Item2.count
Least -
Code: [Select]
Code:
return Item2.count - Item1.count
 
Last edited:
Got it, are these lists static or does it actually check for the flag on each item? For instance, if one item was set to be used in-battle would this be taken into account by the sort or would it be treated as if the flag wasn't on?
 
Only the name list is static. The others check the actual details of the item.
 
Status
Not open for further replies.
Back
Top