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

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Sort Arrays like Array(100,20,1,1,1)
PostPosted: Thu Mar 11, 2004 5:07 am 
Offline
Addict
Addict
User avatar

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.

Thanks in advance?


<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
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 11, 2004 6:03 am 
Offline
Moderator
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
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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 forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye