https://dev.kronoz.win/r/marzneshin.git
1import { UserType } from "@marzneshin/modules/users";
2
3export const userTrafficSortingFn = (userA: UserType, userB: UserType) => {
4 if (userA.data_limit && userB.data_limit) {
5 const rowAUsedTraffic = (userA.used_traffic / userA.data_limit) * 100
6 const rowBUsedTraffic = (userB.used_traffic / userB.data_limit) * 100
7 return (
8 rowAUsedTraffic > rowBUsedTraffic
9 && rowAUsedTraffic !== rowBUsedTraffic
10 ) ? 1 : -1
11 }
12 return 0
13}