in reply to Sorting file with regex
As the other monks have said, your post doesn't include enough information. Especially the input is unclear: Does the file consist entirely of lines that look like your single example? Can you provide more examples of input?
Anyway, here's one way to do it in Perl that makes use of Tie::File and the Schwartzian transform. It may be a little naive due to lack of sample input.
use Tie::File; tie my @file, 'Tie::File', $filename or die "tie failed"; @file = map {$$_[0]} sort { $$a[1] cmp $$b[1] } map { /^\\bibitem\{.+?\}\s*(.+)$/; [$_, $1] } @file; untie @file;
On the other hand, maybe you should look into a more "complete" module such as Text::BibTeX?
|
|---|