Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: reordering lists

by paulbort (Hermit)
on Jan 21, 2004 at 23:00 UTC ( [id://323054]=note: print w/replies, xml ) Need Help??


in reply to Re: reordering lists
in thread reordering lists

Only half-serious:
You can solve the problem of needing to put picture 5 between pictures 2 and 3 by assigning it sequence 2.5. Unlike the BASIC numbering method, scalability is only limited by the accuracy of your floating-point package. :-)

Now for a real-world answer:
If you don't care about normalization, use separate tables for house and pictures, and put a big nasty text column on the house table. Put the comma-separated list of pictures for that house in that column, in the order they should be displayed! This will work until there are more pictures for a house than can fit in that column. Base64 numbering would help with this, reducing the column size to two chars per picture for the first 63 pictures. (one data, one separator, assume no use of 0). If you can guarantee an upper limit on the number of pictures (like 64^2-1), you can skip the separator and use unpack().

Re:Linked Lists
Linked lists are a classic solution to this problem in memory, but don't solve the problem of one update for each picture when you want to save the order to the database, unless you use Storable to just dump the whole list into a column, which is not much different from my suggestion above.

--
Spring: Forces, Coiled Again!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://323054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found