dpkg version sorting

Use this as you would use | sort | to sort package names according to dpkg versioning logic:

#!/usr/bin/perl
sub dpkgcomp
{
  return 1 if(system("dpkg --compare-versions $a lt $b"));
  return -1 if(system("dpkg --compare-versions $a gt $b"));
  return 0;
}
@l = <>;
chomp(@l);
@s = sort dpkgcomp @l;
print join("\n", @s), "\n";

Update 30 April 2015: imported on GitHub, added a Python version.

blogroll

social