This is what I do to sort something alphabetically (as opposed to String.length)
Posted by FrozenWinters Aug 08 2010 20:59 GMT in FrozenWinters
- Like?

    public void strings() throws IOException {
        System.out.println("Write somthing, press enter, repeat once");
        BufferedReader inp = new BufferedReader(
                new InputStreamReader(System.in));
        String a;
        String b;
        char c;
        char d;
        a = (inp.readLine()).toLowerCase(); // done before char comparison
        b = (inp.readLine()).toLowerCase();
        int i = 0;
        while (true != false) {
            try {
                c = (a.toCharArray()[i]);
            } catch (ArrayIndexOutOfBoundsException ex) {
                System.out.println(a);
                System.out.println(b);
                return;
            }
            try {
                d = (b.toCharArray()[i]);
            } catch (ArrayIndexOutOfBoundsException ex) {
                System.out.println(b);
                System.out.println(a);
                return;
            }
            if (c == d) {
                i++;
                continue;
            }
            if (c < d) {
                System.out.println(a);
                System.out.println(b);
                return;
            } else {
                System.out.println(b);
                System.out.println(a);
                return;
            }

        }

    }


Replies:

excuse caridge returns done by text tool
BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
Reply by FrozenWinters Aug 08 2010 21:01 GMT
One day pi I'm gonna come back to this post and understand completely what you just *crag*ing posted but I don't think today's that day
Reply by Fallen Shade Aug 08 2010 21:05 GMT
Sign-in to post a reply.