And so forth, the problem I have is with my sort. At any given time I have 200 messages displaying. I sort numerically descending the array to make sure the list displays numerically with the highest value for the Transid at the top. The problem is that once I reach 99999 and roll-over to 00001, the 00001 event displays at the bottom of the list and of course until 200 events occur after this roll-over the page is out of whack. I keep trying to think of exactly what I need to do with additional code at the sort and try fixing this myself, but I have mental block and can't seem to figure it out. Below is the actual code that performs the sorting. Any and all suggestions would be greatly appreciated.Transid | Date | Time | PagerID | Message Description 99996 | Feb10 | 11:18 | sundallas_e | dspmmr3 at 02/10/2005 10:18:04 +CPU Utilization is at 99.73% 99995 | Feb10 | 11:17 | hpdallas_e | zcompass at 02/10/2005 09:57:04 + CPU Utilization is at 100%
### Output Loop. Sub Routine to generate Web Output to ActiveWindow sub webpage_output { while(1) { if ( -e $Statfile ){ open(ACTWIN,">$ActiveWindow") || die "Couldn't open fi +le $ActiveWindow - $!\n"; print ACTWIN "Transid|Datestamp|Timestamp|Ticket|Pager +Id|Message|Status\n"; ### ### changed method of opening getting the last files in the directory ### also changed sort order to display on screen ### April 5, 2004 opendir(CacheDir,$Cache) || die "Couldn't open the dir +ectory $Cache: $!\n"; @filelist=grep { /[0-9]{5}/ } readdir(CacheDir); closedir(CacheDir); @sortlist=sort {$b <=> $a} @filelist; for ($i=0;$i<$MsgCount;$i++) { $filename=$sortlist[$i]; if ($filename) { open(ITEM,"$Cache/$filename"); while(<ITEM>){ chomp; if(/TransID=(.*)/){$a=$1;} if(/DATE=(.*)/){$b=$1;} if(/TIME=(.*)/){$c=$1;} if(/TICKET=(.*)/){$d=$1;} if(/PagerID=(.*)/){$e=$1;} if(/Message=(.*)/) { $f=$1; $cont="Y"; next; } if(/Status=(.*)/){$g=$ +1; $cont="";next;} if ($cont eq "Y") { $f=$f.$_; } } close(ITEM); print ACTWIN "$a|$b|$c|$d|$e|$f|$g\n"; } } close(ACTWIN); unlink($Statfile) || die "Couldn't delete $Statfile - +$!\n"; } sleep($naptime); } }
20050110 Edit by ysth: code tags around sample data
20050212 Edit by castaway: Changed title from 'sort a nuts'
In reply to Sorting through a rollover by onegative
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |