Google Answers Logo
View Question
 
Q: table sorting ( No Answer,   0 Comments )
Question  
Subject: table sorting
Category: Computers > Internet
Asked by: deliriumtremens-ga
List Price: $2.00
Posted: 03 May 2006 14:50 PDT
Expires: 05 May 2006 18:46 PDT
Question ID: 725216
"link list.tmp1" is like this...

<a href="http://www.sitex.com/">Site X</a>
<a href="http://www.sitey.com/">Site Y</a>
<a href="http://www.sitem.com/">Site M</a>
<a href="http://www.siten.com/">Site N</a>
<a href="http://www.sitez.com/">Site Z</a>

I mean, it is a text link list.

I need to add all these links to a table, but if I add it like...

<table>
<tr>
<td>*text link 1*</td>
<td>*text link 2*</td>
<td>*text link 3*</td>
<td>*text link 4*</td>
</tr>
<tr>
<td>*text link 5*</td>
<td>*text link 6*</td>
<td>*text link 7*</td>
<td>*text link 8*</td>
</tr>
</table>

...and my visitors want to read it by alphabetic order, they will have
to read it from left to right, then down, then from left to right, then
down and so on, but I want my visitors to be able to read it by
alphabetic order from top to bottom, then right, then from top to
bottom, then right and so on...

I want my table to be like this...

<table>
<tr>
<td>*text link 1*</td>
<td>*text link 3*</td>
<td>*text link 5*</td>
<td>*text link 7*</td>
</tr>
<tr>
<td>*text link 2*</td>
<td>*text link 4*</td>
<td>*text link 6*</td>
<td>*text link 8*</td>
</tr>
</table>

There are 47 links in "link list.tmp1". These links need to be sorted
in the order that I want in the table. I am trying to do that! Here
goes more progress.

#!C:\Programas\xampplite\perl\bin\perl.exe

print "Content-type: text/html\n\n";

open(OLDLIST, "<link list.tmp1");
 open(NEWLIST, ">link list.tmp2");

  $count=1;

  $up1=0;
  $up2=0;

  $place=1;

  @newlist=();

  foreach $line(<OLDLIST>)
   {
    $up1=int $count / 12;
    $up2=int $count % 12;

    $place=($up1 + 1) * 12 + ($up2 + 1);

    $newlist[$place]=$line;

    $count++;
   };

  print NEWLIST @newlist;

 close(NEWLIST);
close(OLDLIST);

Clarification of Question by deliriumtremens-ga on 03 May 2006 16:59 PDT
Here goes more progress...

By the way, here goes more progress...

#!C:\Programas\xampplite\perl\bin\perl.exe

print "Content-type: text/html\n\n";

open(OLDLIST, "<link list.tmp1");
 open(NEWLIST, ">link list.tmp2");

  @newlist=();

  $countX=0;
  $countY=0;

  $afterX=0;
  $afterY=0;

  $place=0;

  foreach $line(<OLDLIST>)
   {
    $countX++;
    $countY++;

    while ($countX > 12)
     {
      $countX = $countX - 12;
     };

    $afterX = ($countX - 1) * 4;
    $afterY = ($countY - 1) % 4;

    $newlist[$place]=$line;
   };

  print NEWLIST @newlist;

 close(NEWLIST);
close(OLDLIST);
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy