Hashtable ordering makes no sense

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?

hashtables are no ordered set.
They are meant to be high performance associative sets.

Guess what you are looking for is more something like an Array / ArrayList

Aha! This Unity javascript takes a little getting used to but this appears to work just fine:

class Jobs extends System.Object {
   static var allJobs:Array = [
      {"name": "Pesky Bunnies", "reward": 100},
      {"name": "Awesome", "reward": 1000000}
   ];
	
   static function getAvailableJobs():Array {
      return allJobs;
   }
}
// Get the list of jobs
var jobs:Array = Jobs.getAvailableJobs();
Debug.Log(jobs[0]["name"]);
Debug.Log(jobs[1]["name"]);

// yields Pesky Bunnies, Awesome (as expected)