Last active
February 7, 2019 15:47
-
-
Save lostsnow/6e8fb6df96dbc088cbbf261584f2ac39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sort(mapping a, mapping b) | |
{ | |
return a["value"] - b["value"]; | |
} | |
int main(object me, string arg) | |
{ | |
mapping m = (["a": 2, "b": 3, "c": 1]); | |
mapping *a, *b; | |
mixed *mk; | |
int i; | |
mk = keys(m); | |
a = allocate(sizeof(mk)); | |
for (i = 0; i < sizeof(mk); i++) | |
{ | |
a[i] = ([ "key": mk[i], "value": m[mk[i]] ]); | |
} | |
b = sort_array(a, (: sort :)); | |
printf("%O\n", b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment