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-03-2007, 05:45 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
sortdescending

How are sortascending() and sortdescending() sorting the array? I know it sorts by lowest/highest first.

So for the most part I have a number infront of a few words because I was hoping when i sortdescending() it would arrange them by the numbers.

Eventually this is the output afterwords

PHP Code:
8 N1
7 N2
20 N3
12 N4
0 N5
0 N6
0 N7 
Everything is passing right but they just arent sorting correctly. I was wondering if this is because the array contains numbers and letters?

Its more of a question of how this functions.
Reply With Quote
  #2  
Old 01-03-2007, 08:32 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I doubt it would be able to sort an array with different data types.... It would be cool if you can add a param like sortdescending("int"); or similar
Reply With Quote
  #3  
Old 01-03-2007, 08:56 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by Twinny View Post
I doubt it would be able to sort an array with different data types.... It would be cool if you can add a param like sortdescending("int"); or similar
I guess it would be nice also if you could sort multidimentional arrays by one of their elements, which would put all of them in order.

sortdescending(0); maybe like you said could sort the array by all the [0] elements. That would be handy.
Reply With Quote
  #4  
Old 01-03-2007, 09:00 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
You're better off using sorting algorithms.
Reply With Quote
  #5  
Old 01-03-2007, 12:50 PM
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
sortascending() and sortdescending() are currently only sorting by string value. There is also the function obj.sortbyvalue(varname,vartype,ascending) although it only sorts by variables of the array members, not by the content of the array member itself, eventually sortbyvalue() could be expanded to also allow that
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 08:57 PM.


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