had opencode clean up all my nonsense comments too
This commit is contained in:
@@ -44,20 +44,13 @@
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Sort the players inside each bracket before returning the data
|
||||
// Sort players: placed first (ascending), unplaced last
|
||||
if (data && data[0] && data[0].registeredPlayers) {
|
||||
data[0].registeredPlayers.forEach((bracket: any) => {
|
||||
bracket.items.sort((a: any, b: any) => {
|
||||
// 1. Both have no placement (placement === 0) -> keep original order
|
||||
if (a.placement === 0 && b.placement === 0) return 0;
|
||||
|
||||
// 2. 'a' has no placement, but 'b' does -> move 'b' to the top
|
||||
if (a.placement === 0) return 1;
|
||||
|
||||
// 3. 'a' has a placement, but 'b' doesn't -> keep 'a' on top
|
||||
if (b.placement === 0) return -1;
|
||||
|
||||
// 4. Both have placements -> sort ascending (1st, 2nd, 3rd, etc.)
|
||||
return a.placement - b.placement;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user