Skip to content

Commit bfa0000

Browse files
committed
Improved sort
1 parent 9e76ebc commit bfa0000

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

site/src/pages/ManagementSettingsPage/OrganizationSettingsPage.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ const OrganizationSettingsPage: FC = () => {
5050
const editableOrg = organizations
5151
.sort((a, b) => {
5252
// Prefer default org (it may not be first).
53-
if (a.is_default) {
54-
return -1;
55-
} else if (b.is_default) {
56-
return 1;
57-
}
58-
return 0;
53+
// JavaScript will happily subtract booleans, but use numbers to keep
54+
// the compiler happy.
55+
return (b.is_default ? 1 : 0) - (a.is_default ? 1 : 0);
5956
})
6057
.find((org) => canEditOrganization(permissions[org.id]));
6158
if (editableOrg) {

0 commit comments

Comments
 (0)