mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Fix kind sorting differently on client and build
This commit is contained in:
parent
e659bbd6e4
commit
9f2a499e26
4 changed files with 37 additions and 21 deletions
21
helpers/sort-list.js
Normal file
21
helpers/sort-list.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
export function byTimeThenNull (appA, appB) {
|
||||
// console.log('appA.lastUpdated', appA.lastUpdated)
|
||||
|
||||
// equal items sort equally
|
||||
if (appA.lastUpdated === appB.lastUpdated) {
|
||||
return 0;
|
||||
}
|
||||
// nulls sort after anything else
|
||||
else if (appA.lastUpdated === null) {
|
||||
return 1;
|
||||
}
|
||||
else if (appB.lastUpdated === null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return appB.lastUpdated.timestamp - appA.lastUpdated.timestamp
|
||||
}
|
||||
|
||||
export default function (appList) {
|
||||
return appList.sort(byTimeThenNull)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue