From the description and images I think it sorts items in inventory in a more natural way. Like swords always before bows and staves, and such. I don't use it, but many times cursed why I have gloves made from various materials scattered all over my bag
That's how it could be useful.
Anyway, when you asked the question, I took it as an excersise. The UI code is probably a mess, I was just picking pieces to make it work, but I managed to add a "Level" sorting header to the inventory, and with the way I've overridden sortFn, you can replace orderByItemLevel with custom comparison function.
Lua Code:
local function orderByItemLevel(data1, data2)
local lv1 = GetItemLevel(data1.bagId, data1.slotIndex)
local lv2 = GetItemLevel(data2.bagId, data2.slotIndex)
return lv1 < lv2
end
local function initializeCustomInventorySortFn(inventory)
inventory.sortFn = function(entry1, entry2)
local sortKey = inventory.currentSortKey
local sortOrder = inventory.currentSortOrder
local res
if type(sortKey) == "function" then
if inventory.currentSortOrder == ZO_SORT_ORDER_UP then
res = sortKey(entry1.data, entry2.data)
else
res = sortKey(entry2.data, entry1.data)
end
else
local sortKeys = ZO_Inventory_GetDefaultHeaderSortKeys()
res = ZO_TableOrderingFunction(entry1.data, entry2.data, sortKey, sortKeys, sortOrder)
end
return res
end
end
-- call from EVENT_ADD_ON_LOADED
local function experimentalSortInventoryByLevel()
local invSortBy = ZO_PlayerInventorySortBy
local nameHeader = invSortBy:GetNamedChild("Name")
local levelHeader = CreateControlFromVirtual("$(parent)Level", invSortBy, "ZO_SortHeader")
levelHeader:SetAnchor(RIGHT, nameHeader, RIGHT, -5, 0)
levelHeader:SetDimensions(80, 20)
ZO_SortHeader_Initialize(levelHeader, "Level", orderByItemLevel,
ZO_SORT_ORDER_UP, TEXT_ALIGN_RIGHT, "ZoFontHeader")
local inventory = PLAYER_INVENTORY.inventories[INVENTORY_BACKPACK]
initializeCustomInventorySortFn(inventory)
inventory.sortHeaders:AddHeader(levelHeader)
end