Sort by Name

gameboomvr

New member
Hi, I want to sort by name my ItemInfo grid every time I press a button. I used code from documentation, but I don't know how to make it work. Where should I place it or which method should I use to update sorting. I don't use UI Designer and i have category filters as well.
 
The best place to start would be the Feature scene on Filters&Sorters. That scene showcases a few working examples of different use cases.
That will give you a high level idea of how it's supposed to work.

If you want to sort once and not continously though you'll have to do it via code directly.
Use this function:
Code:
m_InventoryGrid.SortItemIndexes(itemInfoComparer);
like specified here in the docs.

itemInfoComparer is what you would expect. I think (not 100% sure). but you might be able to do something around those lines
Code:
m_InventoryGrid.SortItemIndexes((x,y)=> x.Item.Name.CompareTo(y.Item.Name));

I hope that helps
 
Thanks, m_InventoryGrid.SortItemIndexes(itemInfoComparer); and then InventoryGrid.Draw() works for me :)
I'm doing also
InventoryGrid.BindGridFilterSorter(this);
InventoryGrid.UseGridIndex = false;
Because I want to allow user to switch off and on the sorting or choose another one. Just wanna to clearify if this is really necessary or can I simplify the code?

Ps. I couldnt find the answer because I was searching about sorting in docs: Item Info Filters & Sorters, not Inventory Grid
 
Last edited:
Because I want to allow user to switch off and on the sorting or choose another one. Just wanna to clearify if this is really necessary or can I simplify the code?
I think that sounds right to me, I don't think there's a "simpler" way to do this.
Ps. I couldnt find the answer because I was searching about sorting in docs: Item Info Filters & Sorters, not Inventory Grid
That makes sense let me update the docs to add this in the filter and sorter docs
 
Top