# PureBasic Forum

 It is currently Wed May 22, 2013 8:14 am

 All times are UTC + 1 hour

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Posted: Thu Aug 16, 2001 11:05 pm
 PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by Cantor.

Hello!

Is there a way to sort (quick sort or shell sort) the items
of an array (numerical or strings)?

Will there be a sort command implemented in future versions of PB?

Greetings,
Martin.

--
Best regards,
Martin

Top

 Post subject: Posted: Fri Aug 17, 2001 12:21 am
 PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by wayne1.

; From pure basic examples/sources
; QuickSort example in PureBasic !
;

DefType.l

Dim a.l(10000)

Procedure QuickSort(g.l, d.l)

If g = v

ok = 0
Repeat
If j>0
j=j-1
Else
ok=1
EndIf

If a(j) 0

tmp.l = a(i)
a(i) = a(j)
a(j) = tmp
Until j <= i

t = a(j)
a(j) = a(i)
a(i) = a(d)
a(d) = t

QuickSort(g, i-1)
QuickSort(i+1, d)
EndIf

EndProcedure

a(10) = 1
a(20) = 256
a(100) = -200
a(1000) = -230
a(40) = -50

QuickSort(0,10000)

For k=0 To 5
MessageRequester("First elements", Str(a(k)), 0)
Next

For k=9999 To 10000
MessageRequester("Last elements", Str(a(k)), 0)
Next

End

Edited by - wayne1 on 17 August 2001 01:23:53

Top

 Post subject: Posted: Fri Aug 17, 2001 12:24 pm
 PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by Cantor.

Thanks a lot!

The procedure works well.

Greetings,
Martin.

--
Best regards,
Martin

Top

 Post subject: Posted: Mon Aug 20, 2001 7:39 pm
 PureBasic Guru

Joined: Tue Apr 22, 2003 7:42 pm
Posts: 16777210
Restored from previous forum. Originally posted by fred.

Quote:
Thanks a lot!

The procedure works well.

Greetings,
Martin.

--
Best regards,
Martin

Of course it does . Seriously, I will add lighning fast sorting for Array (any type, from byte to floats including string). It's already present in the AmigaOS version.

Fred - AlphaSND

Top

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

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: ozzie, Shield and 5 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 - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite