By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Sorting Problem

P: n/a
Hi

I want to make categories on a website, like folders that have a tree to
them...

I was wondering if the best way is to have it in an array and have them all
point to each other and sort them with some sort of algorithm.

Is this the best way to do it?
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <3B*******************@news02.tsnz.net>, Hayden Kirk wrote:
Hi

I want to make categories on a website, like folders that have a tree to
them...

I was wondering if the best way is to have it in an array and have them all
point to each other and sort them with some sort of algorithm.


I prefer to store that data in database.
I ended up with categories that are able to contain other categories.
The data structure looks like a tree.

If you search the web for a Tree implementation in SQL, i'm pretty sure
you'll get a lot of hits. One of them will be about nested sets.
As soon you understand how that works, you could have a look at the
NestedSets package at http://pear.php.net
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.