I understand that there is no built in way to sort a Hashtable, but even when I build my own sorting mechanism the sorting doesn’t stick.
Here are some example code snippets. With the following hashtable:
// The job names and the number of jobs that must be completed to be available
static var allJobs:Hashtable = {
"Pesky": 1,
"Awesome": 1,
"Killtacular": 2,
"Parachute": 3,
"Dude!": 5
};
I loop through and make buttons out of the hashtable:
for (jobName in allJobs.Keys) {
if (GUILayout.Button(jobName)) {
Application.LoadLevel(jobName);
}
}
I get:
Pesky
Killtacular
Parachute
Dude!
Awesome
It doesn’t matter what order I have the hashtable in. So I guess I’ll just have to stick to arrays?
I need to have a sortable (or at least predictable) array of arrays like:
var test = {
"one" : {"title":"onetitle", "description":"onedescription"},
"two" : {"title":"twotitle", "description":"twodescription"}
}
Is there a good way to do this?