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]
2 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]2 years ago
7 0

Answer:

Here the code is given as follows,

Explanation:

You might be interested in
What considerations should you make when deciding on the size of a table?
Kisachek [45]

Answer:

You should consider the number of cells needed for data, labels, titles, and formulas.

Explanation:

4 0
3 years ago
Personal computer is the rise of what?​
gogolik [260]

Answer:

Overuse injuries of the hand.

Obesity.

Muscle and joint problems.

Eyestrain.

Behavioural problems including aggressive behaviour.

6 0
3 years ago
To copy the formatting of selected text to another place in the document use _____.
ANEK [815]
To copy the formatting of selected text to another place in the document use the paintbrush AKA. Format painter
7 0
3 years ago
Rupa would like to quickly insert a table into her document without having to worry about formatting the data in the table. Whic
USPshnik [31]
Internet tap and log on application
6 0
3 years ago
Read 2 more answers
When adding clip art to a slide you are limited to the pictures stored on your computer?
77julia77 [94]
The answer is No.  <span>When adding clip art to a slide you are not limited to the pictures stored on your computer.  </span><span>We are not limited to using clip art from our computer. Any clip art can be used, but if it is from another source, it must first be saved to your computer as a </span>file<span>. </span>
8 0
3 years ago
Other questions:
  • He smallest network is a ______________________, which is a network of personal devices, such as the network you use when you sy
    5·1 answer
  • Which of the following statements regarding EFT is false? EFT still requires the endorsement of a check EFT allows payment to be
    11·1 answer
  • In python,_______ are used to define the conditions necessary for a while loop to run.
    7·2 answers
  • Which of the following is not a true statement? You can import a table or a query directly from an Access database into an Excel
    15·1 answer
  • A Windows application which demands a lot of raw processing power to execute repetitive complex calculations is a good candidate
    9·1 answer
  • How do you think computers have helped improve documentation, support and services within the healthcare industry
    13·1 answer
  • Identify what a computer needs to
    14·1 answer
  • Find the median and mean of the data set below: 29 17 40 12 29
    6·1 answer
  • What is used to accurately position objects on the slide using a single horizontal and vertical line that intersects in the cent
    12·2 answers
  • Tom is not sure how to code contents such as title and meta elements. These are coded as ____ elements.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!