The stupid question is the question not asked | |
PerlMonks |
Re: Re: reordering listsby paulbort (Hermit) |
on Jan 21, 2004 at 23:00 UTC ( [id://323054]=note: print w/replies, xml ) | Need Help?? |
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!
In Section
Seekers of Perl Wisdom
|
|