Skip to content

Instantly share code, notes, and snippets.

@lostsnow
Last active February 7, 2019 15:47
Show Gist options
  • Save lostsnow/6e8fb6df96dbc088cbbf261584f2ac39 to your computer and use it in GitHub Desktop.
Save lostsnow/6e8fb6df96dbc088cbbf261584f2ac39 to your computer and use it in GitHub Desktop.
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