Code:
sort_maps() {
new x,y,z,d
new bool:swap,bool:done,bool:dupe
new temp[32]
for ( x = 0; x < totalmaps; x++ ) {
for ( y = x + 1; y < totalmaps; y++ ) {
swap = false
done = false
dupe = true
for (z = 0; z < 32; z++) {
if ( T_LMaps[x][z] != T_LMaps[y][z]) {
if ( T_LMaps[x][z] > T_LMaps[y][z] && !done) swap = true
done = true
dupe = false
}
}
if (swap) {
temp = T_LMaps[x]
T_LMaps[x] = T_LMaps[y]
T_LMaps[y] = temp
}
else if (dupe) {
for ( d = y; d < totalmaps; d++ ) {
T_LMaps[d] = T_LMaps[d + 1]
}
y = totalmaps--
x--
}
}
}
}
Just wanted to share since I spent some time on this, dunno if anyone has done thins B4 in one of thier plugins or not.
The array being sorted is T_LMaps
There is also dupe checking in there and it could easily be taken out.
Please let me know if there is any more effecient way of doing this, this was the best I could come up with and it works at least.
__________________