Vmod page - how the entries are sorted?

Designer
Από Romania
Μέλος από Ιουν 2024

On the Vmod page, I want to name the Vmod's in a logical way, however I dont know how the netries are sorted on this page:
admin/?app=vmods&doc=vmods

its not A-Z - I would prefer the vmod entries to be sorted from A-Z so I can organise them when I give the Vmod name for example:

Admin - Vmod - 1
Admin - Vmod - 2
Front - Vmod - xxx

and so on

LiteCart Fan
Από Netherlands
Μέλος από Δεκ 2022

https://github.com/litecart/litecart/blob/dev/public_html/admin/vmods.app/vmods.inc.php#L183
$vmods is the array

sort alphabetically by name:

function sortByName($a, $b) {
  return strcmp($a["name"], $b["name"]);
}
usort($vmods, 'sortByName');

So in file admin/vmods.app/vmods.inc.php

...
    $vmods[] = $vmod;

  }

function sortByName($a, $b) {
  return strcmp($a["name"], $b["name"]);
}
usort($vmods, 'sortByName');
...
Designer
Από Romania
Μέλος από Ιουν 2024

Thank you jackmaessen - that worked - I can now name my vmods in a way that it groups itself from Z-A for a clearer view as I am started to have lots of vmods..

tim
Founder
Από Sweden
Μέλος από Μαΐ 2013
tim

And even more lightweight is this:

uasort($vmods, function($a, $b) {
  return strcmp($a['name'], $b['name']);
});

And as arrow functions:

uasort($vmods, fn($a, $b) => strcmp($a['name'], $b['name']));

https://www.php.net/manual/en/functions.arrow.php

Designer
Από Romania
Μέλος από Ιουν 2024

cool

Εσύ
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.