It is currently Wed Jun 19, 2013 7:10 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject:
PostPosted: Tue Dec 30, 2008 3:14 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5184
Location: Germany
Since PB 4.30, SortStructuredList (and SortList) use Mergesort which is a stable sort, so if you first sort all the list by titles and then again by album you will get a list which is sorted by album and each album is sorted by title.

Note that this does not work with Arrays, as SortArray uses Quicksort which is unstable. (ie the sorting of the secondary key would be lost)

_________________
Perl – The only language that looks the same before and after RSA encryption.
-- Keith Bostic


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 6:06 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 09, 2003 10:08 pm
Posts: 635
Location: Nottingham
@ freak:

Please add to the Help documentation for SortStructuredList() and SortList() that they are stable sorts.

Is there any chance in the future for the other sort routines to have a stable sort option in addition to the standard method?

_________________
Anthony Jordan


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2009 3:55 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Jan 18, 2006 7:40 pm
Posts: 103
Location: Hamburg
@akj

It's not possible to use Mergesort for arrays, because Mergesort can't work in place, that means the array would have to be taken apart and then put back together again.

With lists you can use the already existend link headers of the list to do it.

For more in depth explanation use google and search for "Mergesort wiki"


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2009 3:59 pm 
Offline
Always Here
Always Here
User avatar

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7304
Location: Norway
But it's possible to make a stable quicksort.

_________________
Woa, I set up a web server.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 4:47 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 1587
Location: Berlin, Germany
technicorn wrote:
It's not possible to use Mergesort for arrays, because Mergesort can't work in place, that means the array would have to be taken apart and then put back together again.

It is possible to use Mergesort for arrays, of course.

Regards, Little John

_________________
Math problems?
Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 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