Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Combining single-key sorts to form concatenated-key sort

Re: Combining single-key sorts to form concatenated-key sort

From: Brian Inglis <Brian.dot.Inglis_at_SystematicSw.ab.ca>
Date: Sat, 03 Feb 2001 14:57:23 -0700
Message-ID: <3kvo7tg2j6dade65v2862jf16hfii008gk@4ax.com>

On 3 Feb 2001 06:51:48 -0000, Frog2
<FrogRemailer_at_NoReply.Invalid> wrote:

>I'm trying to sort some records. Each record consists of three data fields I wish to use
>as a concatenated key for sorting purposes and some detail fields. All three key fields
>are alphanumeric. All key fields in every record will always contain a value (no NULLs).
>
>Here's the problem: the language I'm using has a sort function but that function will
>only let me sort on *one* field of my choice, not all three at once. So how can I achieve
>a primary - secondary - tertiary sort of these records. Presumably there's some scalable
>way to sort/merge each lower key with the key above it (or perhaps the reverse, sort from
>primary key down to lowest-order key).
>
>What I've come with so far is make a list of each key field's unique values
> unique_p , unique_s, unique_t
>sorted in the order I want. But then how could I use these to extract the records in
>correct overall sorted order?
>
>One subtlty - one or more key fields will contain only numbers. So if I try an "strcat-'em
>all-together" solution I'll get bit by the "10-sorts-after-1-not-2" problem.
>
>Any ideas on how to do this? Please post any replies back to the list so that others may
>learn.
>
>
>TIA,
>
>Mike

Sort by least significant key field, and so on up to most significant key field. Think about whay it works.

Thanks. Take care, Brian Inglis Calgary, Alberta, Canada

-- 
Brian_Inglis_at_CSi.com 	(Brian dot Inglis at SystematicSw dot ab dot ca)
				use address above to reply
Received on Sat Feb 03 2001 - 15:57:23 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US