title: Ordered Dictionary in c# and unity3d FIREBASE
body: <p>I currently have a firebase project that parses data from the web.</p>
  
  <p>All the data is coming down however I'm wanting to reverse order the results.</p>
  
  <p>I achieve this by doing the following code</p>
  
  <pre><code>public class ExampleItemModel{
  
      public string name;
      public string score;
      public string level;
      public int iconIdx1, iconIdx2, iconIdx3;
  }
  </code></pre>
  
  <p>Then in my fetch data method :-</p>
  
  <pre><code>    public  void GetDataFromFireBase(string reference, Action&lt;ExampleItemModel[]&gt; onDone){
  
  
           FirebaseDatabase.DefaultInstance
            .GetReference(reference).OrderByChild("score")
            .GetValueAsync().ContinueWith(task =&gt; {
              if (task.IsFaulted) {
                // Handle the error...
                print("Error: " + task.Exception);
              }
              else if (task.IsCompleted) {
                DataSnapshot snapshot = task.Result;
                // Do something with snapshot...
  
                  var items = snapshot.Value as Dictionary&lt;string, object&gt;;
                  int count = items.Count;
                  var results = new ExampleItemModel[count];
                  int i = 0;
                  foreach(var item in items){
                      results[i] = new ExampleItemModel();
  
                      //print("items =  " + item);
                         var values = item.Value as Dictionary&lt;string, object&gt;;
  
                              if (reference == "scores"){
                              print("values count =" + values.Count);
  
                                  foreach(var value in values){
  
                                      if(value.Key == "name"){ results[i].name = "" + value.Value;}
                                      if(value.Key == "score"){ print("Score = " + value.Value); results[i].score = "" + value.Value;}
                                      if(value.Key == "level"){ results[i].level = "" + value.Value;}
  
                                  }
                              i++;
                              }
              onDone(results);
  
  }
  
            });
  
  }
  </code></pre>
  
  <p>Ive tried the following : -</p>
  
  <p>in firebase rules I've set </p>
  
  <pre><code>  ".indexOn":"score",
  "score": {
    ".indexOn": ".value"
  }
  </code></pre>
  
  <p>I've also tried to add the following line of code </p>
  
  <pre><code>            results = results.OrderByDescending( x =&gt; x.score);
              onDone(results);
  </code></pre>
  
  <p>but I get the following error</p>
  
  <p>severity: 'Error'
  message: 'Cannot implicitly convert type 'System.Linq.IOrderedEnumerable' to 'ExampleItemModel[]' [Assembly-CSharp]'
  at: '137,14'
  source: ''</p>
  
  <p>Would anybody please be able to help </p>
  
  <p>thanks</p>