Vmod page - how the entries are sorted?

Designer
Depuis Romania
Membre depuis juin 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
Depuis Netherlands
Membre depuis déc. 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
Depuis Romania
Membre depuis juin 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
Depuis Sweden
Membre depuis mai 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
Depuis Romania
Membre depuis juin 2024

cool

Vous
Ce site n'utilise aucun cookie ni aucune technologie de suivi tierce. Nous pensons pouvoir faire mieux que les autres et nous nous soucions vraiment de votre vie privée.