I am trying to read a text file $f_name which contains lines (terminated by \n).
Each line contains a number (with possible duplicates) and a few words seperated by " | ". (i.e.
1|hello\n
7|goodbye\n
3|Yes\n
2|No\n
20|Maybe\n
)
How can I sort the array of lines based on the number?
I've tried:
if (file_exists($f_name)){
$r=file($f_name);
$sort=sort ($r);reset ($r);
and get the result:
1
20
2
3
7
Please help.
Thanks.