PDA

View Full Version : Sort Order of groups in Data Library



AmadanNaBriona
May 12th, 2020, 15:31
I have a Talents group in my data library that I want to sort either by Letter (alphabetically) or IQ.

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=35241&d=1589293520

It works, except I get this:

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=35242&d=1589293705

You can see that the talents listed by IQ are sorted alphabetically.

I can make it work by setting the aGroupValueOrder for the "byiq" aListViews in my data_library.lua script to be a literal array of numbers, e.g.: {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"}. But it seems like there should be a way to just make it sort numerically?

Relevant code:



["talent"] = {
["byletter"] = {
sTitleRes = "talent_grouped_title_byletter",
aColumns = {
{ sName = "name", sType = "string", sHeadingRes = "talent_grouped_label_name", nWidth=250 },
{ sName = "iq", sType = "number", sHeadingRes = "talent_grouped_label_iq", nWidth=25 },
},
aFilters = {},
aGroups = { { sDBField = "name", nLength = 1 } },
aGroupValueOrder = { },
},
["byiq"] = {
sTitleRes = "talent_grouped_title_byiq",
aColumns = {
{ sName = "name", sType = "string", sHeadingRes = "talent_grouped_label_name", nWidth=250 },
{ sName = "iq", sType = "number", sHeadingRes = "talent_grouped_label_iq", nWidth=25 },
},
aFilters = {},
aGroups = { { sDBField = "iq" } },
aGroupValueOrder = {},
},
},

Trenloe
May 12th, 2020, 15:42
Even though the original field is a number field, the grouped headings are strings - so it's ordering as a string, not a number. So, for it to be in order you can use the 01, 02, 03 ... 09, 10, 11, 12, 13... etc..

So, you can override this using the aGroupValueOrder as you've found, or you could convert the value using a sCustom function in aGroups - but you'd have to then use 01, 02, 03...