Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-21-2007, 07:17 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Sorting arrays

HTML Code:
sortascending() - sorts the array in ascending order (smallest value first)

sortbyvalue(str, str, bool) - sorts the array by the specified variable name, you must also say what variable type it is (e.g. string) and if it should be sorted ascending

sortdescending() - sorts the array in descending order (highest value first)
Has anyone else managed to get these to work?
Reply With Quote
  #2  
Old 01-21-2007, 08:19 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Im pretty sure Ive used sortascending() and sortdescending() in the past, and they've worked.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 01-21-2007, 10:10 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
sortbyvalue works as well:

HTML Code:
function onCreated()
{
  this.array = null;
  addn("B");
  addn("C");
  addn("D");
  addn("A");
  
  echo(this.array[0].name);
  this.array.sortbyvalue("name", "string", false);
  echo(this.array[0].name);
  this.array.sortbyvalue("name", "string", true);
  echo(this.array[0].name);
}

function addn(n)
{
  temp.data = new TStaticVar(@temp.n);
  temp.data.somevar = "test";

  this.array.add(temp.data);
}
outputs:
B (default)
D (descending)
A (ascending)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.