mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-29 20:14:27 -04:00
Add pretty formatting (#29)
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {MAX_INT} from "common/constants";
|
||||
import {MAX_INT} from 'common/constants'
|
||||
|
||||
export function getSortedOptions(options: string[], order: string[] | Record<string, string>) {
|
||||
let parsedOrder: string[]
|
||||
@@ -7,14 +7,12 @@ export function getSortedOptions(options: string[], order: string[] | Record<str
|
||||
} else {
|
||||
parsedOrder = Object.keys(order)
|
||||
}
|
||||
return options
|
||||
.slice()
|
||||
.sort((a, b) => {
|
||||
const ia = parsedOrder.indexOf(a as any)
|
||||
const ib = parsedOrder.indexOf(b as any)
|
||||
const sa = ia === -1 ? MAX_INT : ia
|
||||
const sb = ib === -1 ? MAX_INT : ib
|
||||
if (sa !== sb) return sa - sb
|
||||
return String(a).localeCompare(String(b))
|
||||
});
|
||||
}
|
||||
return options.slice().sort((a, b) => {
|
||||
const ia = parsedOrder.indexOf(a as any)
|
||||
const ib = parsedOrder.indexOf(b as any)
|
||||
const sa = ia === -1 ? MAX_INT : ia
|
||||
const sb = ib === -1 ? MAX_INT : ib
|
||||
if (sa !== sb) return sa - sb
|
||||
return String(a).localeCompare(String(b))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user