# PureBasic Forum

 It is currently Tue Jan 26, 2021 8:09 pm

 All times are UTC + 1 hour

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Sort Arrays like Array(100,20,1,1,1)Posted: Thu Mar 11, 2004 5:07 am

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2308
Location: Argentina
Any idea? Maybe there is some trick that i dont know, i dont use arrays often.

<edited>

This don't work for me:

Code:
OpenConsole()
Dim MyArray(10,1)

For i = 0 To 9
MyArray(i,1) = 10-i
PrintN(Str(MyArray(i,1)))
Next

SortArray(MyArray(),0)
PrintN("")

For ii = 0 To 9
PrintN(Str(MyArray(ii,1)))
Next

Repeat:Until Inkey() <> ""
End

Top

 Post subject: Posted: Thu Mar 11, 2004 6:03 am
 Moderator

Joined: Sat Dec 27, 2003 3:55 am
Posts: 3321
Location: Great Southern Land
Heya ricardo,

It looks like it treats the whole thing as an a one-dimensional array and sorts. 8O

All the values end up in the last few elements of the array, in (6,0) to (10,1) so I assume it stores values internally as a contiguous chunk of values:
(0,0) (0,1) (1,0) (1,1) .. (10,0) (10,1)
and just sorts those values.

Code:
Dim MyArray(10,1)

For i = 0 To 10
MyArray(i,1) = 10-i
For j=0 To 1
Debug Str(i)+":"+Str(j)+" = "+Str(MyArray(i,j))
Next
Next

SortArray(MyArray(),0)

Debug "==="

For ii = 0 To 10
For jj=0 To 1
Debug Str(ii)+":"+Str(jj)+" = "+Str(MyArray(ii,jj))
Next
Next

Weird.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: hrcoder and 43 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite