Skip to content

Commit b712bb6

Browse files
committed
Gemini suggestion
1 parent ce7c0a2 commit b712bb6

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

src/features/cseMachine/CseMachineLayout.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,9 @@ export class Layout {
379379
* JS Slang environment ids are numeric strings that increase monotonically as frames are created.
380380
*/
381381
private static sortNodesByCreation(nodes: EnvTreeNode[]): EnvTreeNode[] {
382-
return [...nodes].sort((left, right) => {
383-
const leftId = Number(left.environment.id);
384-
const rightId = Number(right.environment.id);
385-
const bothNumeric = !Number.isNaN(leftId) && !Number.isNaN(rightId);
386-
387-
return bothNumeric
388-
? leftId - rightId
389-
: String(left.environment.id).localeCompare(String(right.environment.id));
390-
});
382+
return [...nodes].sort((left, right) =>
383+
left.environment.id.localeCompare(right.environment.id, undefined, { numeric: true })
384+
);
391385
}
392386

393387
/** initializes grid */

0 commit comments

Comments
 (0)