Your task is to sort an array list of path names such as

/home/me/cs1
/usr/share
/var/log
/usr/local/jdk1.6.0/jre/lib

Sort by the path length, i.e. the number of slashes in the path name. Path names of the same length should be arranged in lexicographic order (i.e. by calling String.compareTo.) For example, the path names given above will be sorted as

/usr/share
/var/log
/home/me/cs1
/usr/local/jdk1.6.0/jre/lib

Complete the following file:

PathSorter.java

import java.util.Arrays; import java.util.Comparator; public class PathSorter { public String[] sort(String[] paths) { class PathComparator implements Comparator<String> { public int compare(String p1, String p2) { // TODO: Complete this method } private int countSlashes(String p) { return p.length() - p.replace("/", "").length(); } } Arrays.sort(paths, new PathComparator()); return paths; } }