Sorting values in an int array

Started by Baguettator, Wed 21/04/2021 14:27:04

Previous topic - Next topic

Baguettator

#20
Oh ! I didn't see about the "Set" !!

Yes, the game crashes during the game, the compilation worked well. But no need to explore that problem : the "Set" solution is by far the best !

If I understand well, the "set" is automatically sorted ? Or do I need to copy it in a String [] ?

That's my code I'm going to try :

Code: ags
void Tri(this ListBox*)
{
  int t=this.ItemCount;
  Set* s=Set.Create(eSorted, eCaseSensitive);
  for (int i=0 ; i<t ; i++)
  {
    if (this==ListeEquipementsColo || this==ListeEquipementsExp)
    {
      int p=this.Items[i].IndexOf(" ");
      s.Add(this.Items[i].Substring(p+1, this.Items[i].Length));
    }
    else s.Add(this.Items[i]);
  }
  String c[]=s.GetItemsAsArray();
  this.Clear();
  for (int i=0 ; i<t ; i++)
  {
    this.AddItem(c[i]);
  }
}


EDIT : this code worked perfectly, and I think I have understood very well how to manipulate Sets. Thanks a lot !

SMF spam blocked by CleanTalk