PDA

View Full Version : peculiar sorting issue (fg classic, story entries)



tahl_liadon
February 22nd, 2021, 03:02
.
i designate prefix to all fg story entries and use this naming convention:
[part # + *** title ***][section #][subsection alpha][event #]


sample set of prefixes:
136-p1 ***
136-p1-1
136-p1-2
136-p1-2a01
136-p3 ***
136-p3-1
136-p3-2
136-p3-2k05
136-p3-2m11
136-p3-4o1
136-p3-4o2
136-p3-4o3

however, [B]136-p3 *** won't sort property, and fg is placing it out of order in the position below:
136-p1 ***
136-p1-1
136-p1-2
136-p1-2a01
136-p3-1
136-p3-2
136-p3-2k05
136-p3-2m11
136-p3-4o1
136-p3 *** <--- (coincidentally starts on page 2 of story)
136-p3-4o2
136-p3-4o3

i took the same set and put it in google sheet and it sorted correctly as seen in top set.

odd thing is, part 1 and part 2 sort properly with same naming convention.

my current workaround is to add a hyphen: 136-p3- ***

been staring at it for an hour... bug?

Zacchaeus
February 22nd, 2021, 03:59
I think FG sorts up to the first space. But that’s a guess. Usually I’d expect 01.000, 01.001, 02.000 etc for chapter and story ordering so I’m not exactly sure what happens once you introduce letters into the equation.

Moon Wizard
February 22nd, 2021, 08:36
FG uses a pure case-sensitive alphanumeric sort by name when name sorting is used. (lowercase > uppercase, one character compared at a time).

Regards,
JPG

tahl_liadon
February 22nd, 2021, 13:55
FG uses a pure case-sensitive alphanumeric sort by name when name sorting is used. (lowercase > uppercase, one character compared at a time).

.
thx that's seems most obvious... and it seems that's what fg is doing.

but i'm not sure if you had a chance to review and had other insight why that entry would be out of place.

Minty23185Fresh
February 22nd, 2021, 17:06
My experience with the sort, and is has been extensive, due to the Field Filters for All Libraries extension, is that sorting is done with a "shotgun" kind of methodology. Every value in a list is NOT compared against every other value and swapped as needed. Once in a while, you'll experience a peculiarity such as the one shown. It is a built in oddity of the lua library's .sort function. If you really care about it read the lua manual.

Minty23185Fresh
February 22nd, 2021, 17:10
You might be able to see this oddity in action. Add several more pages numbered right around the anomaly. It might straighten itself out. Oddly enough one or two might not be enough.

tahl_liadon
February 22nd, 2021, 17:29
...Once in a while, you'll experience a peculiarity such as the one shown... If you really care about it read the lua manual.
.
lol no, i would not like to read the manual -- i'll take your word for it!

thx much for the insight. will proceed with my workaround; it's not a biggie.

Moon Wizard
February 22nd, 2021, 17:49
Ok, looks like there is some sort of disconnect between sorting functions in the display list; and the internal overall campaign list filtering. I'll rewrite for the next push.

Regards,
JPG

tahl_liadon
February 22nd, 2021, 18:58
I'll rewrite for the next push.
.
cool! thx

Minty23185Fresh
February 22nd, 2021, 21:38
I went searching for a citation to verify what I stated in post #5, but I can't find it.
The lua "programming in lua" pages hint at it but do not specifically state it that way.

IIRC it boils down to this:
when one uses table.sort(myTable, mySortFunction);
every value in myTable is NOT guaranteed to be sent to mySortFunction(a, b)
and most certainly every value in myTable is NOT guaranteed to be compared
in mySortFunction(a, b) to every other value in myTable

I found this to be incredulous, but I verified it for myself a few times when combo box data
in FFAL was not properly sorted. And sure enough, using Debug.console within the sort function,
for tables that failed to sort properly the incorrectly placed data item was never sent to the
sort function.

Moon Wizard
February 22nd, 2021, 21:45
I haven't seen that (either the mention or an example). Do you have an example extension showing a simple table not being sorted correctly with a sort function in table.sort?
(Remember, sorting only works for numerically-indexed tables.)

Regards,
JPG

Minty23185Fresh
February 22nd, 2021, 21:59
I haven't seen that (either the mention or an example). Do you have an example extension showing a simple table not being sorted correctly with a sort function in table.sort?
(Remember, sorting only works for numerically-indexed tables.)

Regards,
JPG

I’m sorry but I do not. I will look for one.

Minty23185Fresh
February 22nd, 2021, 22:53
I haven't seen that (either the mention or an example). Do you have an example extension showing a simple table not being sorted correctly with a sort function in table.sort?
(Remember, sorting only works for numerically-indexed tables.)

Regards,
JPG

I’m sorry but I do not. I will look for one.

I can't do this for a few days, but this what I will attempt, when I get a chance is add more fields to the customfilters (in the 5E data_library). Specifically fields with lots of variations in the data like the NPC Action Names. In general if the fields are mostly alphabetic it should work great, lot's of data. I'll need to avoid fields like Skills where Arcana +12 will be sorted before Arcana +2, without special handling (breaking the field up into the alphabetic prefix and numeric suffix though I believe you already have a special sort function defined for this situation).

Moon Wizard
February 23rd, 2021, 00:17
For an example, don't try to use your extension; or anything else. Try to recreate in a simple extension script without all the extras. If not, it might be something related to all the things you do in your script.

Regards,
JPG

Minty23185Fresh
February 23rd, 2021, 00:53
For an example, don't try to use your extension; or anything else. Try to recreate in a simple extension script without all the extras. If not, it might be something related to all the things you do in your script.

Regards,
JPG
Oh yes totally. I was going to just hack the 5e custom filter definitions into the 5e ruleset data_library....lua file. Avoiding even an extension. I’d just forward the few lines of script to you.

In the very first iteration of FFAL, I did just that only for Spells to test feasibility (while working on the Mystic class extension).

Griogre
February 26th, 2021, 03:27
.
i designate prefix to all fg story entries and use this naming convention:
[part # + *** title ***][section #][subsection alpha][event #]


sample set of prefixes:
136-p1 ***
136-p1-1
136-p1-2
136-p1-2a01
136-p3 ***
136-p3-1
136-p3-2
136-p3-2k05
136-p3-2m11
136-P3-4o1
136-P3-4o2
136-P3-4o3

however, [B]136-p3 *** won't sort property, and fg is placing it out of order in the position below:
136-p1 ***
136-p1-1
136-p1-2
136-p1-2a01
136-p3-1
136-p3-2
136-p3-2k05
136-p3-2m11
136-P3-4o1
136-p3 *** <--- (coincidentally starts on page 2 of story)
136-P3-4o2
136-P3-4o3

i took the same set and put it in google sheet and it sorted correctly as seen in top set.

odd thing is, part 1 and part 2 sort properly with same naming convention.

my current workaround is to add a hyphen: 136-p3- ***

been staring at it for an hour... bug?

Just thought I would mention the 136-p3 *** is there because you use both upper and lower case "P"s. Since it's an alpha sort it is case sensitive. Try converting them all to lower case?

tahl_liadon
February 26th, 2021, 16:04
...you use both upper and lower case "P"s...
.
good observation.

that was an inconsistency error in my re-entering the info here in the post (which i corrected in original message) -- all lowercase.

so that's actaully not the reason, but thx for pointing it out.

Moon Wizard
March 3rd, 2021, 05:00
A fix for this was pushed in the Tuesday update.

Regards,
JPG

tahl_liadon
March 3rd, 2021, 13:36
A fix for this was pushed in the Tuesday update.
.
.
woot!

Minty23185Fresh
March 7th, 2021, 18:05
To report back on this. I have not been able to reproduce evidence that supports claims I made in posts #5 and #10 of this thread. I can only attribute my claims to temporary insanity or self-aggrandizing. :pirate:

tahl_liadon
March 10th, 2021, 00:18
.
so... i wonder if fg (after this last fix) used the ascii sort order (https://support.ecisolutions.com/doc-ddms/help/reportsmenu/ascii_sort_order_chart.htm), and if not, which?

it sorted my list, but this time, it put [space] after [hyphen] -- as a matter of fact, it put [space] as last sort order -- as in:

136-p2x concluding p2
136-p3-1 title
136-p3-3m07
136-p3-4o3
136-p3x concluding p3
136-p3 *** part 3 <-----

so now i have to reassign / re-title a bunch of entries, then add [hyphen] to sort properly:

136-p2x concluding p2
136-p3-0 *** part 3 <-----
136-p3-1 title
136-p3-3m07
136-p3-4o3
136-p3x concluding p3

i think the fix used a different convention where [space] is not first in sorting.

anyway, a bit of a mess, throwing a bunch of things out of order so i had to rename stuff. ugh lol