subject
Computers and Technology, 06.07.2021 23:50 ozieera

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 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);

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:30
Some of the first computer games were created in the early 1970s by college students experimenting after hours to see what the were capable of doing.
Answers: 3
question
Computers and Technology, 22.06.2019 19:30
When using a public computer or network, you should always
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
question
Computers and Technology, 23.06.2019 18:50
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
You know the right answer?
It is common for people to name directories as dir1, dir2, and so on. When there are ten or more dir...
Questions
question
Computers and Technology, 28.04.2021 03:50
question
Mathematics, 28.04.2021 03:50
question
Mathematics, 28.04.2021 03:50