Skip to content

Commit

Permalink
Fix crash running yarn flags --sort flag (#28344)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Feb 17, 2024
1 parent 62a9c7d commit fef30c2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/flags/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,15 @@ for (const flag of allFlagsUniqueFlags) {
let sorted = table;
if (isDiff || argv.sort) {
const sortChannel = argToHeader(isDiff ? argv.diff[0] : argv.sort);
sorted = Object.fromEntries(
Object.entries(table).sort(([, rowA], [, rowB]) =>
rowB[sortChannel].toString().localeCompare(rowA[sortChannel])
)
);
const sortBy =
sortChannel === 'flag'
? ([flagA], [flagB]) => {
return flagA.localeCompare(flagB);
}
: ([, rowA], [, rowB]) => {
return rowB[sortChannel].toString().localeCompare(rowA[sortChannel]);
};
sorted = Object.fromEntries(Object.entries(table).sort(sortBy));
}

if (argv.csv) {
Expand Down

0 comments on commit fef30c2

Please sign in to comment.