code: private void sortPathByDepth(Path[] paths) {
      Arrays.sort(paths, new Comparator<Path> (){
        @Override
        public int compare(Path o1, Path o2) {
          return ((Integer)o1.depth()).compareTo(o2.depth());
        }});
    }
docs: Sort the path array by depth
  @param paths