Skip to content

Commit

Permalink
Sort robots with numbers in reverse
Browse files Browse the repository at this point in the history
Puts the most recent year's KitBot first in the list
  • Loading branch information
jwbonner committed Dec 19, 2024
1 parent 9fb24a0 commit d59049f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/assetsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,14 @@ export function loadAssets(): AdvantageScopeAssets {
// Built-in fields added in code to end of list
assets.field3ds.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));

// All robots in asset files, no special sorting required
assets.robots.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
// All robots in asset files, sort numbers in reverse to put the most recent KitBot at the top
assets.robots.sort((a, b) => {
if (/^\d/.test(a.name) && /^\d/.test(b.name)) {
return -a.name.localeCompare(b.name, undefined, { numeric: true });
} else {
return a.name.localeCompare(b.name, undefined, { numeric: true });
}
});

// Built-in joysticks added in code to beginning of list
assets.joysticks.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));
Expand Down

0 comments on commit d59049f

Please sign in to comment.