Download
(5 Kb)
Download
Updated: 05/20/19 11:53 AM
Compatibility:
Elsweyr (5.0.5)
Wrathstone (4.3)
Murkmire (4.2)
Wolfhunter (4.1)
Summerset (4.0)
Dragon Bones (3.3)
Clockwork City (3.2)
Horns of the Reach (3.1)
Morrowind (3.0)
Homestead (2.7)
One Tamriel (2.6)
Shadows of the Hist (2.5)
Dark Brotherhood (2.4)
Thieves Guild (2.3)
Orsinium (2.2.4)
Updated:05/20/19 11:53 AM
Created:05/31/14 12:26 AM
Monthly downloads:1,740
Total downloads:138,434
Favorites:46
MD5:
LibSort  Popular! (More than 5000 hits)
Version: 2.r1
by: Wobin, Baertram, CrazyDutchGuy, katkat42
LibSort

See GitHub for a decently formatted API

v2r0 - Removed LibStub dependency! Please just use the global variable LibSort instead now to reference this librray

For examples of usage, see MrPlow and SousChef

Currently, the way ESO sorts items is essentially by column, you have a data point for each item, eg, name and you sort the list of objects by that data point.

One thing that this default sorting mechanism offers, however, is a tiebreaker option. If we're sorting by name and a tiebreaker is required, because we are comparing two items with the same name, it falls to the tiebreaker datapoint to determine order of result, eg stackSize

Now the general sorting of items in the real world doesn't just fall to a single data point, or two. It generally requires a series of different datapoints to sort by, and we can take advantage of this 'tiebreaker' to chain together lists of different datapoints to sort by. So we can sort by Name, then by StackSize, then by SlotId.

That's well and fine for what's existing in the current set of datapoints, however we have access to a lot more information about the item than is currently being stored.

To do this, however, we need to inject the required datapoints into the list object so that it has the required information to process the sort order as ascertained by our adjustment of how the tiebreakers chain together.

First we prehook ChangeSort. This will allow us to pick out the inventory being looked at, process the entries in there to inject the appropriate information, and then pass back to the original ChangeSort for the actual sorting.

We now have information about the item, where it's from (slotType) and where it is (bag and index)

And thanks to the new API, we have two new functions that will return information about the item in regards to what sort of weapon or armour it is.

So as an example, we'll use the new Weapon info function to inject data to allow the game to sort by weapontype

Code:
GetItemWeaponType(link)
is the function we're using to obtain the information required.

Or at least through

Code:
local link = GetItemLink(bag, index)
local weaponType = GetItemWeaponType(link)
If we then inject this information into the data object

Code:
control:GetParent().dataEntry.data.weaponType = weaponType
we can then include another entry into the sortKeys for default header

Code:
local sortKeys = ZO_Inventory_GetDefaultHeaderSortKeys()
sortKeys["weaponType"] = {isNumeric = true, tiebreaker = "name"}
and we will end up sorting by the type of weapon returned by that function. (Note that as it's a pure number, and not necessarily in the order you may want, you'll have to actually adjust the real value of the datapoint to something more suitable)

In any case, now that we know what we need to do, this library should do most of the heavy lifting for you. Chances are I'll have to give it it's own Settings panel so people can reorder the sort order as they wish, but you should be able to register your addon to allow data injection and process the index/bag combinations to store whatever datapoints you want.
v2r1
Fixed filename
v2r0
-Updated API for Elsweyr
-Removed LibStub dependency! Please just use the global variable LibSort instead now to reference this librray
r8 - API 100026 Wrathstone (needs a standalone copy of the library "LibStub" installed to function!)
r7 - API 100009
r6 - API 100008
r5 - Fixed error due to variables not being initialized
r4 - Wait till ingame is loaded first before hooking
Optional Files (0)


Archived Files (9)
File Name
Version
Size
Uploader
Date
2.r0
5kB
Baertram
05/19/19 04:38 PM
1.r8
5kB
Baertram
02/15/19 03:18 PM
1.0 r7
6kB
CrazyDutchGuy
09/28/14 12:30 PM
1.0 r6
6kB
CrazyDutchGuy
08/04/14 12:22 PM
1.0 r5
6kB
CrazyDutchGuy
06/28/14 12:38 PM
1.0 r4
6kB
CrazyDutchGuy
06/28/14 11:26 AM
1.0 r3
6kB
CrazyDutchGuy
06/28/14 08:30 AM
1.0
6kB
CrazyDutchGuy
05/31/14 12:26 AM
0B
05/31/14 12:26 AM


Post A Reply Comment Options
Unread 07/31/14, 01:41 PM  
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view AddOns

Forum posts: 89
File comments: 187
Uploads: 9
This will break in upcoming patch, no time yet to fix as it is a serious problem ...
Report comment to moderator  
Reply With Quote
Unread 05/31/14, 10:33 AM  
Wobin
 
Wobin's Avatar
AddOn Author - Click to view AddOns

Forum posts: 78
File comments: 192
Uploads: 7
Re: Sorting

Originally Posted by METALPUNKS
Will this add on the version that comes with sous chef sort all my inventory or just ingredients? Should I download mr plow as well of I want it all sorted?

Oh and thank you for this.
SousChef will just sort the ingredients, if you want everything else, grab MrPlow
Report comment to moderator  
Reply With Quote
Unread 05/31/14, 10:19 AM  
METALPUNKS

Forum posts: 14
File comments: 28
Uploads: 0
Sorting

Will this add on the version that comes with sous chef sort all my inventory or just ingredients? Should I download mr plow as well of I want it all sorted?

Oh and thank you for this.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.