sort pkgs by deps