Advertisement
cd62131

print original order and sorted order index

Oct 11th, 2017
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.27 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. my @data = map {chomp;$_+0} <>;
  5. my @sort_index = map {$_->[1]} sort {$b->[0]<=>$a->[0]} map {[$data[$_],$_]} 0..$#data;
  6. print map {"$data[$_->[0]] $_->[1]\n"} sort {$a->[0]<=>$b->[0]} map {[$sort_index[$_],$_+1]} 0..$#data;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement