[futurebasic] Re: [FB] Sorting Records on multiple key fields within the record

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2009 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sun, 26 Apr 2009 09:09:30 -0700
On Apr 26, 2009, at 2:46 AM, Robert Purves wrote:

>
> Brian Stevens wrote:
>
>> Does anyone have code to enable the use of two ( or more )  key  
>> fields in one sort?  In the contrived example below it shows data  
>> sorted alphabetically ( ascending ) on Store name and within a  
>> given store name sorts Product alphabetically. Finally, it sorts by  
>> date for the same product. Data is in records and index sorting is  
>> the target but any method is fine. Thought I'd ask before working  
>> through this. TIA....Brian S.
>>
>> Store Name		Product	Date
>>
>> MyGroceryStore	Eggs  	10/11/2009  ( mm/dd/yyyyy )
>> MyGroceryStore	Milk	  	10/10/2009
>> MyGroceryStore	Milk    	10/11/2009
>> ...
>> ...
>> TheirGrocery		Milk  	12/11/2009
>> TheirGrocery		Milk  	12/13/2009
>
> The simplest way is to use a stable sorting algorithm <http://en.wikipedia.org/wiki/Sorting_algorithm 
> >.
> Sort on date first. Then sort on product. Then sort on store name.

Thank you Robert for clarifying the core method. That is very helpful.

  Besides the various sorting methods( and I'm aware picking the  
correct sort method is important ) there are some Core Foundation  
calls to be considered and I'm still examining options.

Thanks again....Brian S.