Skip to content

Commit

Permalink
sort by winning amount
Browse files Browse the repository at this point in the history
  • Loading branch information
magiodev committed Jun 11, 2024
1 parent 0946be5 commit 8a8b1ae
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions frontend-ms/src/components/Game/PlayersAllocations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="col players-allocations mb-3">
<h3 class="text-center">User Allocations</h3>

<div class="overflow-x-scroll" v-if="Object.entries(statistics.playerStatistics).length">
<div class="overflow-x-scroll" v-if="Object.entries(sortedPlayerStatistics).length">
<table class="table always-left mb-0 small">
<thead>
<tr>
Expand All @@ -17,7 +17,7 @@
</tr>
</thead>
<tbody>
<tr v-for="(stats, address) in statistics.playerStatistics" :key="address">
<tr v-for="(stats, address) in sortedPlayerStatistics" :key="address">
<td><UserAddressComponent :cut="10" :address="address"/></td>
<td>{{ displayAmount(stats.totalBet, 2) }}
<CoinComponent/>
Expand Down Expand Up @@ -284,6 +284,15 @@ export default {
});
return {playerStatistics, totalFees, totalRedistributed};
},
sortedPlayerStatistics() {
return Object.entries(this.statistics.playerStatistics)
.sort(([, a], [, b]) => b.redistributionShare - a.redistributionShare)
.reduce((obj, [key, value]) => {
obj[key] = value;
return obj;
}, {});
}
},
Expand Down

0 comments on commit 8a8b1ae

Please sign in to comment.