array of objects

I want to save a string (word) and int (score) into an array and then sort based on the int.

Im using Javascript. I’ve tried making a class then saving an object in the array:

public class wordClass 
	var word : String;
	var score : int;

var wordObject = wordClass();

wordObject.word = wordString;
wordObject.score = wordScore;

Debug.Log("CLASS TEST: " + PermanentVariables.wordsFound[1].word);

//PermanentVariables are is where the array is stored. I made this so that I can access these from any scene
public static class PermanentVariables
    public var wordsFound = new Array();
    public var gameScore : int;
    public var levelScore : int;


I get the error:
Assets/Scripts/GameScript.js(112,77): BCE0019: ‘word’ is not a member of ‘Object’.

Is there a better way to do this? I haven’t written the sort code yet.

Please read this. Javascript array is untyped, so if you want type-specific operation, you need to do type-casting:

Debug.Log("CLASS TEST: " + (PermanentVariables.wordsFound[1] as wordClass).word);

Why don’t you use the .NET’s List< T > instead; the only thing Javascript array can do but the List< T > can’t is to store different types of variable, which is not needed at all in your case.