Re: [Nolug] php: list sorting algorithm help

From: John Tiedeman <jdtiede_at_sstar.com>
Date: Tue, 23 Dec 2003 22:36:30 -0600
Message-ID: <web-3963881@sstar.com>

On Tue, 23 Dec 2003 22:26:26 -0600
  "Clinton R. Nixon" <crnixon@anvilwerks.com> wrote:
>On Tue December 23 2003 23:03, Christopher M. Jones wrote:
>> I need an algorithm to sort a list in the following way (in php):
>> ...
>> The first field is a unique ID, the second is an association with some
>> other entry in the list. This allows topics and subtopics (represented
>> above with dashes) of infinite levels to be contained in the same list
>> (there are reasons I need this).
>>
>> I have been struggling with this. I think I am at the limit of my
>> programming prowess. Can anybody help, or give me the crucial pointer
>> in the right direction?
>
>That is no way to store data - there's no real identifiers for sub-lists.
>Also
>- is this a hash (associative array) in PHP? I'm trying to figure out
>what's
>your key here and what's your value. If the first number is the key, a
>simple
>sort of the keys gives you your second list.
>
>E-mail me on-list or off-list with some more info about what your data
>structure is, and I'll run you through what to do.
>
>- Clinton R. Nixon
>___________________
>Nolug mailing list
>nolug@nolug.org

==========================================================================
It looks to me like a simple sort on the first column will do it. Your list
of how it should end up seems to indicate that the items in the second
column are to stay with their original first-column partners (the key).
___________________
Nolug mailing list
nolug@nolug.org
Received on 12/23/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST