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
What is the process for creating a new merge document for address labels?
Archy [21]

Answer:

In Word, click Mailings > Start Mail Merge > Step-by-Step Mail Merge Wizard to start the mail merge wizard. Choose Labels, and then click Next: Starting document. Choose Label options, select your label vendor and product number, and then click OK. Click Next: Select recipients.

Explanation:

6 0
3 years ago
Read 2 more answers
Select the steps for adding artwork into a placeholder on a presentation slide
Sloan [31]

Answer:

   Open the presentation that you want to add a slide to.

   In the pane that contains the Outline and Slides tabs, click Slides, and then click where you want to add a slide.

Explanation:

6 0
3 years ago
In an advertisement, a speed specification, such as 2.66 ghz, indicates the speed of the microprocessor?
Ray Of Light [21]

Answer:

yes / true

Explanation:

it is one of the factors in determining the speed of the microprocessor

5 0
2 years ago
Which of the following sets of values constitutes a valid RSA public key encryption system?
Gelneren [198K]

Answer:

oh I can't it looks so confusing

6 0
3 years ago
What type of rock is formed from other rocks being subjected to great heat and pressure?
Sonbull [250]
Hi,

I believe the best answer would be B, Metaphoric. 

And also, just for future reference, you might want to put questions like this in the "Science" category. I guarantee it will be answered faster, and by users who specialize in that particular subject.☺

~Elisabeth
8 0
3 years ago
Other questions:
  • Netflix suggestions ?
    15·2 answers
  • You work in a customer call center. Martin is on the phone asking about the difference between solid-state drives (SSDs), hybrid
    6·1 answer
  • The source must decode a message before it can be sent. select one: <br> a. True <br> b. False
    7·1 answer
  • Lindsey also needs to calcite the commissions earned each month. If the company earns $200,000 or more in a month, the commissio
    5·1 answer
  • What is the missing line of code?
    7·2 answers
  • The symbol located to the left of a code number that identifies a code description that has been revised is _____.
    12·1 answer
  • Generalized goals are more likely to be achieved than specific goals. True or False
    7·1 answer
  • When planning your App what difficulties did come across and why?
    5·2 answers
  • Vector images take up much less space when saved to a computer or storage device because computers and storage devices just need
    14·2 answers
  • This ingredient is often used as decoration for both hot and cold dessert​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!