title: Sorting a List <string, int> in Unity c#
body: <p>I'm trying to make a rankingtable for some university work. The better way that came in mind was creating a List with String, Integer for each position. I searched in the documentation : <a href="https://unity3d.com/es/learn/tutorials/modules/intermediate/scripting/lists-and-dictionaries?gq=sort" rel="nofollow noreferrer">https://unity3d.com/es/learn/tutorials/modules/intermediate/scripting/lists-and-dictionaries?gq=sort</a> where i found the perfect example for my problem, so i started working. Now, i've created the Interfece: </p>
  
  <pre><code>public class Name_Puntuation: IComparable
  
  public string namePlayer;
  public int puntuation;
  
  public Name_Puntuation( string newNomPlayer, int newPuntuation){
  
      nomPlayer = newNomPlayer;
      puntuation= newPuntuation;
  
  }
  
  public int CompareTo(Name_Puntuation other){
  
      if (other == null) {
          return 1;
  
      }
  
      return Puntuation - other.Puntuation;
  }
  </code></pre>
  
  <p>I also added to my GameController what i want to do with the list. This class controlls the canvas of the game. We print all the information to textfields, and so i wanted to do with the ranking:</p>
  
  <pre><code>public class GameController : MonoBehaviour {
  
      public List &lt;Name_Puntuation&gt; ranking;
  
      void Start () {
  
          playerName= GetComponent&lt;MenuController&gt; ().inp; //name the player choosed
  
          ranking = new List&lt;Name_Puntuation&gt; ();
  
      }
  
      void Update () {  }
  
      public void Ranking(){
          int puntuation= punts;
          ranking.Add (new Name_Puntuation(playerName, puntuation)); 
  
          ranking.Sort ();
  
          foreach (Nom_Puntuacio p in ranking) {
  
              print (p.playerName+ " " + p.puntuation);
  
          }
  
      }
  }
  </code></pre>
  
  <p>but now I'm stuck. I want to add the information to the list when the game is finnished. When do i have to call the function? rankig.sort(); will sort the puntuation (integer) of each player? AN dlast question, how do I have to restart the process to create a new player?
  Any advice will be very helpfull. </p>
  
  <p>Thanks, Marco</p>