Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-27-2009, 11:23 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
sortsub()

.sortsubascending(index)
.sortsubdescending(index)

Will sort an array from the index provided in the subarrays.

Example:
this.test = {{"one",1},{"five",5},{"three",3},{"four",4},{"two ",2}};

this.test.sortsubascending(1);


Will return:
this.test = {{"one",1},{"two",2},{"three",3},{"four",4},{"five ",5}};

I'm not exactly sure of the syntax, but I'd like to see some way for this to be easily done.
Reply With Quote
  #2  
Old 06-27-2009, 11:34 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
so basicly

temp.array.sortsubascending(index)
temp.array.sortsubdescending(index)

temp.array.subarray(index).sortascending()
temp.array.subarray(index).sortdescending()


Wouldn't something like that work?

Edit: Nevermind, Wouldn't work as I don't think they return anything..?
__________________
Reply With Quote
  #3  
Old 06-27-2009, 11:38 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
This kind of thing is possible if you use an array of TStaticVars and use sortbyvalue().

Quick Example:
PHP Code:
function OnCreated() {
  
temp.test = {arrayMember("one"1), arrayMember("five"5), arrayMember("three"3), arrayMember("four"4), arrayMember("two"2)};
  
temp.test.sortbyvalue("num"nulltrue);  //Sorts the 'num' values by floating point value (ascending)
  
  
for (temp.membertemp.test) {
    echo(
temp.member.num SPC temp.member.text);
  }
}

function 
arrayMember(textnum) {
  
temp.result = new TStaticVar();
  
temp.result.text temp.text;
  
temp.result.num temp.num;
  return 
temp.result;

Result:
NPC Code:
1 one
2 two
3 three
4 four
5 five

__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #4  
Old 06-27-2009, 11:45 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Chompy View Post
so basicly

temp.array.sortsubascending(index)
temp.array.sortsubdescending(index)

temp.array.subarray(index).sortascending()
temp.array.subarray(index).sortdescending()


Wouldn't something like that work?

Edit: Nevermind, Wouldn't work as I don't think they return anything..?
If that did work, it would simply sort the data in the subarray. What I'm suggesting is a way to sort the array, from data within a subarray.
Reply With Quote
  #5  
Old 07-20-2009, 01:27 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
The easiest way to sort such arrays right now is to set an attribute of each array member (temp.array[i].sortvalue = temp.array[i][1]) and then use sortbyvalue (temp.array.sortbyvalue("sortvalue","int",true))
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 07:53 PM.


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