I cooked up an array that simulates cycling through a file line by line. Then, after assigning those values to a new array ($final_ar), I sorted them as you wanted. Use this code to sort. I'm certain you can pick the top ten (each sequence can be referenced by $final_ar[<seqence number here>])
After you get your top ten numbers, use strpos() or strstr() to find which line of $tmpar they came out of and that is how you get the line. If you still need more help, let me know.
$tmpar = array("1,997891093,,Sent", "1,997891394,,Sent","2,997891093,,Sent", "3,997891394,,Sent");
var_dump($tmpar);
do
{
$string = current($tmpar);
$length = strlen($string);
$firstcomma = strpos($string, ",");
$sequence=substr($string,0,$firstcomma-$length);
$final_ar[$sequence][] = substr($string,$firstcomma+1, strpos($string,",",$firstcomma+1)-$length);
}
while(next($tmpar));
reset($final_ar);
do
{
$currkey = key(current($final_ar));
$tmp = current($final_ar);
rsort($tmp);
}
while(next($final_ar));