If you wanted to iterate over a mapping--but need it sorted, you should first extract the keys, then sort the keys array, then iterate over the sorted keys array:
int i;
mapping m;
object *k;
...
k = keys(m);
k = sort_array(k, 1);
for (i=0; i < sizeof(k); i++) {
// do something with m[k[i]]
// ...
}