1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Veseljchak [2.6K]
3 years ago
8

It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating syst

em 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 digit as strings, and then compare the numeric values of the digits.
Your program should work with the provided test program
DirectorySortDemo.java.
Call the class you write DirectoryComparator.java.
Submit the two files in your submission.
DirectoryComparator.java
DirectorySortDemo.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.collections;
public class DirectorySortDemo
{
public static void main (String [] args)
{
String dirNames ("dir12", "dir5", "dir9", "dirl", "dir4",
"lab10", "1ab2", "lab7", "lab17", "lab8",
"quiz8", "quiz10", "quiz11", "quiz12",
"dirll", "dir8", "dir7", "dir15", "dir3");
ArrayList directories = new
ArrayList<> (Arrays.asList (dirNames));
System.out.println ("Unsorted List:");
System.out.println (directories);
Collections.sort (directories, new DirectoryComparator ());
System.out.println ():
System.out-println ("Sorted List: ");
System.out.-println (directories);
Computers and Technology
1 answer:
Vikki [24]3 years ago
7 0

Answer:

Here the code is given as follows,

Explanation:

You might be interested in
a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
Usimov [2.4K]
You yourself put the answer to the question in the Question. the answer is paragraph. lol
7 0
3 years ago
Read 2 more answers
The approved systems design document is used by programmers, the personnel department, and information systems personnel.
Crazy boy [7]
True because I have never seen that True or false answer before
5 0
3 years ago
How are air masses and fronts the same. And how are they different. ​
Sergeu [11.5K]

Answer:

Air Masses are warmer air while front is an area of cold air that comes out warm. Font is a place where two of the air masses meet. Font is the borderline between an air mass.

Let me know if I was correct? Hope I could be of help!

Explanation:

7 0
3 years ago
Why we need to interpret the drawing and plans
scoray [572]

Technical drawing is essential for communicating ideas in industry and engineering.

5 0
3 years ago
What is the name of the User-defined function that is mentioned in the code?
Marizza181 [45]

The name of the user defined function is: footballMatch

6 0
3 years ago
Other questions:
  • Which of the following would an interactive media proffessional must likely need
    9·1 answer
  • In step 2 of the mail merge process you must be prepared to
    6·2 answers
  • What color does Sam obtain when he mixes white with a color? Sam is painting a landscape and needs to paint the sky light blue.
    9·2 answers
  • Consider the following C code fragment:
    10·1 answer
  • . Virtualization simplifies the use of resources, isolates users from one another, supports replication and mobility, but exacts
    7·1 answer
  • What are the two types of computer keyboards and how are they different?
    6·2 answers
  • A laptop gets recycled by an e-waste recycling company once it can't be used anymore. Which stage of the hardware lifecycle does
    7·1 answer
  • What is a benefit of naming cells and ranges?
    8·2 answers
  • Suppose you want to boot a VM from its virtual DVD drive, but it boots to the VM’s hard drive. Which of the following could be t
    12·1 answer
  • What can you do to make sure no one outside your company can gain access to its wireless network?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!