Question: It is common for people to name directories as dir 1 , dir 2 , and so on. When there are ten or more directories,
It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating system displays them in dictionary order, as dir1, dir10, dir11, dir12, dir2, dir3, and so on. That is irritating, and it is easy to fix. Provide a comparator that compares strings that end in digit sequences in a way that makes sense to a human. First compare the part before the digits as strings, and then compare the numeric values of the digits.
Step by Step Solution
3.41 Rating (157 Votes )
There are 3 Steps involved in it
ANSWER public class CompareDirs implements Comparator public static final Pattern DIRPATTER... View full answer
Get step-by-step solutions from verified subject matter experts
