Avatars in Gallery are Unsorted

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26546
Joined: Fri Aug 29, 2008 9:49 am

Re: Avatars in Gallery are Unsorted

Post by Mick »

Mick wrote: Tue Jan 31, 2023 10:36 amwhy would … phpBB choose to sort in such a nonsensical way?
I know there has to be a reason but I can’t see it.

ksort — Sort an array by key in ascending order versus natsort — Sort an array using a "natural order" algorithm
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
User avatar
Anișor
Translator
Posts: 273
Joined: Tue Jan 08, 2013 9:36 pm
Location: Arbroath, Angus, Scotland
Contact:

Re: Avatars in Gallery are Unsorted

Post by Anișor »

Mick wrote: Sat Feb 04, 2023 11:23 am
Mick wrote: Tue Jan 31, 2023 10:36 amwhy would … phpBB choose to sort in such a nonsensical way?
I know there has to be a reason but I can’t see it.

ksort — Sort an array by key in ascending order versus natsort — Sort an array using a "natural order" algorithm
Maybe because ksort has a flags parameter you can use to get other results.
Like ksort($avatar_list, SORT_NATURAL); which will get the exact same result as natsort while natsort is doing only this.

Sorting type flags:
  • SORT_REGULAR - compare items normally; the details are described in the comparison operators section
  • SORT_NUMERIC - compare items numerically
  • SORT_STRING - compare items as strings
  • SORT_LOCALE_STRING - compare items as strings, based on the current locale. It uses the locale, which can be changed using setlocale()
  • SORT_NATURAL - compare items as strings using "natural ordering" like natsort()
  • SORT_FLAG_CASE - can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
Formerly known as Neculai Anisor
Discord: Criminus#1996
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26546
Joined: Fri Aug 29, 2008 9:49 am

Re: Avatars in Gallery are Unsorted

Post by Mick »

But, if the user can’t select any of the options available with ksort without making code changes, it seems a bit pointless. I suppose my real point is if you’re going to sort sort in a way that’s useful. Maybe an extension would be in order (no pun intended :) ) if possible?

Thanks for the explanation BTW.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
Post Reply

Return to “[3.3.x] Support Forum”