mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Sort apps by date then null
This commit is contained in:
parent
38c2954d23
commit
1d15ce87f4
1 changed files with 22 additions and 1 deletions
|
|
@ -40,6 +40,27 @@ import LinkButton from '~/components/link-button.vue'
|
|||
import appList from '~/app-list.json'
|
||||
import gameList from '~/game-list.json'
|
||||
|
||||
// console.log('appList.length', appList.length)
|
||||
// console.log('gameList.length', gameList.length)
|
||||
|
||||
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 {
|
||||
components: {
|
||||
Search,
|
||||
|
|
@ -53,7 +74,7 @@ export default {
|
|||
computed: {
|
||||
appList() {
|
||||
return [
|
||||
...appList,
|
||||
...appList.sort(byTimeThenNull),
|
||||
...gameList
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue