Skip to content

Commit

Permalink
Merge pull request #748 from hackclub/sort-ships-by-most-recent
Browse files Browse the repository at this point in the history
Sort ships by most recent
  • Loading branch information
maxwofford authored Nov 13, 2024
2 parents 2c3846d + 59fcf45 commit 6a294e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/harbor/shipyard/ships.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ export default function Ships({
}
}

setShippedShips(Array.from(shippedShipsMap.values()) as Ship[])
const sortedShips = Array.from(shippedShipsMap.values()).sort(
(a, b) => new Date(b?.createdTime) - new Date(a?.createdTime),
) as Ship[]
setShippedShips(sortedShips)
}, [ships])

// Populate shipChains with data from shippedShips in useEffect to avoid updating on every render
Expand Down

0 comments on commit 6a294e8

Please sign in to comment.