Skip to content

Commit

Permalink
Sort ships by most recent
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Nov 13, 2024
1 parent 4ccd4a0 commit 59fcf45
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 59fcf45

Please sign in to comment.