Re: [Nolug] php: list sorting algorithm help

From: Andrew S. Johnson <andy_at_asjohnson.com>
Date: Tue, 23 Dec 2003 22:45:32 -0600
Message-Id: <200312232245.32520.andy@asjohnson.com>

On Tuesday 23 December 2003 10:26 pm, Clinton R. Nixon 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
>
In databases such as Oracle this is known as tree-walking. It's fairly routine,
so I wouldn't think you'd have too much trouble finding info on it.

Andy

___________________
Nolug mailing list
nolug@nolug.org
Received on 12/23/03

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