Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   sortdescending (https://forums.graalonline.com/forums/showthread.php?t=71193)

Andy0687 01-03-2007 05:45 AM

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.

Twinny 01-03-2007 08:32 AM

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 >_<

Andy0687 01-03-2007 08:56 AM

Quote:

Originally Posted by Twinny (Post 1260225)
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.

Gambet 01-03-2007 09:00 AM

You're better off using sorting algorithms.

Admins 01-03-2007 12:50 PM

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


All times are GMT +2. The time now is 10:40 AM.

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