Sort apps by date then null

This commit is contained in:
Sam Carlton 2020-11-21 15:37:52 -06:00
parent 38c2954d23
commit 1d15ce87f4

View file

@ -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
]
}