diff --git a/pages/index.vue b/pages/index.vue index 14fa595..7074869 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -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 ] }