1. question about sequence sorting

------=_NextPart_000_000D_01BE99D8.626C4140
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, Col22 (Colin Ellis) here with a little questionette.

I have a sequence of x length, of sequences of 4 atoms.
e.g.
sequence snafu
snafu =3D {{1,3,5,8},{1,2,3,4}, ..... ,{1,3,5,7}}

My question is, What would be the most efficient/(any) way of sorting=20
the sequences(of four) into ascending order (fourth atom in the sequence
being the one to sort by).

help appreciated,
Thank you in advance, Col22

------=_NextPart_000_000D_01BE99D8.626C4140
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#b0d0d8>
<DIV><FONT face=3DArial size=3D2>Hi, Col22 (Colin Ellis) here with a =
little=20
questionette.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have a sequence of x length, of =
sequences of 4=20
atoms.<BR>e.g.<BR>sequence snafu<BR>snafu =3D {{1,3,5,8},{1,2,3,4}, =
.....=20
,{1,3,5,7}}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My question is, What would be the most=20
efficient/(any) way of sorting <BR>the sequences(of four) into ascending =
order=20
(fourth atom in the sequence<BR>being the one to sort by).</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>help appreciated,<BR>Thank you in =
advance,=20

------=_NextPart_000_000D_01BE99D8.626C4140--

new topic     » topic index » view message » categorize

2. Re: question about sequence sorting

I have wanted to tackle this very thing.
I just haven't done so as of yet.
Sorting this way is actually rather trivial.
All you have to do is take the 4th elements FROM the list
and create a new list with them.  then sort that list.
BUT you must tag the position that those items originated from
and use that tag to reorganize the other list to match that
arrangement.


PS: My site has now been slightly updated.
    Checkout THANKS TO.  You just might be listed.

       Lucius L. Hilley III
       ICQ: 9638898
       AIM: LLHIII
http://www.cdc.net/~lhilley

On Sun, 9 May 1999 04:57:05 +0100, colin ellis
<noonian at SUNG79.FREESERVE.CO.UK> wrote:

>Hi, Col22 (Colin Ellis) here with a little questionette.
>
>I have a sequence of x length, of sequences of 4 atoms.
>e.g.
>sequence snafu
>snafu = {{1,3,5,8},{1,2,3,4}, ..... ,{1,3,5,7}}
>
>My question is, What would be the most efficient/(any) way of sorting
>the sequences(of four) into ascending order (fourth atom in the sequence
>being the one to sort by).
>
>help appreciated,
>Thank you in advance, Col22
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: question about sequence sorting

On Sun, 9 May 1999 04:57:05 +0100, colin ellis
<noonian at SUNG79.FREESERVE.CO.UK> wrote:

>Hi, Col22 (Colin Ellis) here with a little questionette.
>
>I have a sequence of x length, of sequences of 4 atoms.
>e.g.
>sequence snafu
>snafu = {{1,3,5,8},{1,2,3,4}, ..... ,{1,3,5,7}}
>
>My question is, What would be the most efficient/(any) way of sorting
>the sequences(of four) into ascending order (fourth atom in the sequence
>being the one to sort by).

I think this is the reason for the custom_sort() routine.
Take a look a csort.ex in the demo directory for an example.

Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: question about sequence sorting

>I have a sequence of x length, of sequences of 4 atoms.
>e.g.
>sequence snafu
>snafu =3D {{1,3,5,8},{1,2,3,4}, ..... ,{1,3,5,7}}
>
>My question is, What would be the most efficient/(any) way of sorting=20
>the sequences(of four) into ascending order (fourth atom in the sequence
>being the one to sort by).
>

        Colin, in the euphoria home base archive there is a section called db or
data bases. One of the files therein is  called
        enhanced database by Art Adamson

        It contains techniques for sorting a simple multifield data base,
patterned after the Craig example, but modified so it can sort on the
first, second, third, or whatever field you want.
        The technique should be easily modified to do your job. The file is
6x12.zip meaning 6 fields 12 characters each. this can be modified to use
your 4x4 data. It may not be the fastest however. Let me know if you think
I can help you.
I can probably mail you a copy of 6x12.zip if necessary but I would
        prefer
that yu download it from Bob Craig.

 Bye, Art Adamson


Art Adamson, The Cincinnati Engine Man,  euclid2 at email.com

new topic     » goto parent     » topic index » view message » categorize

5. Re: question about sequence sorting

On Sun, 9 May 1999, Irv Mullins wrote:

] On Sun, 9 May 1999 04:57:05 +0100, colin ellis
] <noonian at SUNG79.FREESERVE.CO.UK> wrote:
]
] >Hi, Col22 (Colin Ellis) here with a little questionette.
] >
] >I have a sequence of x length, of sequences of 4 atoms.
] >e.g.
] >sequence snafu
] >snafu = {{1,3,5,8},{1,2,3,4}, ..... ,{1,3,5,7}}
] >
] >My question is, What would be the most efficient/(any) way of sorting
] >the sequences(of four) into ascending order (fourth atom in the sequence
] >being the one to sort by).
]
] I think this is the reason for the custom_sort() routine.
] Take a look a csort.ex in the demo directory for an example.
]
] Irv
]

Hmm. I smell an on-the-fly coming up...

include sort.e

function compare4th(sequence a, sequence b)
    if length(a) != length(b) or length(b) != 4 then
        return {} -- should cause an error
    end if
    return compare(a[4], b[4])
end function
constant compare4th_id = routine_id("compare4th")

sequence snafu
snafu = { Put your stuff here }

-- Sort Snafu
snafu = custom_sort(compare4th_id, snafu)

-- WARNING: Coded without testing. Syntax may be off.

HTH, :)
Carl

--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail........: cyrek- at -bigfoot.com -- Remove hyphens. Ta :)
URL...........: http://www.bigfoot.com/~cyrek/
Uncrackable...: "19.6A.23.38.52.73.45 25.31.1C 3C.53.44.39.58"

new topic     » goto parent     » topic index » view message » categorize

6. Re: question about sequence sorting

include sort.e

function compare_4th_element( sequence a, sequence b )
  compare( a[4], b[4] )
end function

sorted = custom_sort( routine_id( "compare_4th_element" ), unsorted )

Hope this helps.
Lionel

>From: colin ellis <noonian at SUNG79.FREESERVE.CO.UK>
>Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU>
>To: EUPHORIA at LISTSERV.MUOHIO.EDU
>Subject: question about sequence sorting
>Date: Sun, 9 May 1999 04:57:05 +0100
>
>Hi, Col22 (Colin Ellis) here with a little questionette.
>
>I have a sequence of x length, of sequences of 4 atoms.
>e.g.
>sequence snafu
>snafu = {{1,3,5,8},{1,2,3,4}, ..... ,{1,3,5,7}}
>
>My question is, What would be the most efficient/(any) way of sorting
>the sequences(of four) into ascending order (fourth atom in the sequence
>being the one to sort by).
>
>help appreciated,
>Thank you in advance, Col22


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu