## 5:字符串数组排序问题

1000ms

65536kB

ncdec 3 Hello World! You're right! haha! you're wrong!

You're right! Hello World! haha! you're wrong!

JP06

`import java.io.IOException;import java.util.Collections;import java.util.Comparator;import java.util.LinkedList;import java.util.Scanner;public class Main {         static Scanner in = new Scanner(System.in);     static int MAXN=10000+100;    static void dfs(long p,int n)     {          return ;     }    public static void main(String args[])throws IOException  {//      int n=in.nextInt();//      int m=in.nextInt();//      int[] a=new int[n+1];//     //      for(int i=1;i<=n;i++)//      {//          a[i]=in.nextInt();//      }                 String s;         s = in.nextLine();         char[] c = s.toCharArray();         int len=s.length();         LinkedList<String> l=new LinkedList<String>();         int n=in.nextInt();         in.nextLine();         for(int i=1;i<=n;i++)         {             String a=in.nextLine();                          //System.out.print(a);             l.add(a);         }         if(s.equals("inc"))         {             Collections.sort(l);                           for(String t:l)             {                 System.out.println(t);             }         }         else if(s.equals("dec"))         {             Collections.sort(l);             Collections.reverse(l);             for(String t:l)             {                 System.out.println(t);             }         }         else if(s.equals("ncinc"))         {             Collections.sort(l, new Comparator<String>(){            public int compare(String str1, String str2)           {                     str1=str1.toUpperCase();                    str2=str2.toUpperCase();            return str1.compareTo(str2);           }             }        );                          for(String t:l)             {                 System.out.println(t);             }         }         else if(s.equals("ncdec"))         {             Collections.sort(l, new Comparator<String>(){                    public int compare(String str1, String str2)                   {                             str1=str1.toUpperCase();                            str2=str2.toUpperCase();                    return str1.compareTo(str2);                   }                     }                );            Collections.reverse(l);             for(String t:l)             {                 System.out.println(t);             }         }            }         }`