Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring whitespaces #12

Open
krasa opened this issue Apr 22, 2020 · 0 comments
Open

Ignoring whitespaces #12

krasa opened this issue Apr 22, 2020 · 0 comments

Comments

@krasa
Copy link

krasa commented Apr 22, 2020

Ignoring whitespaces does not really produce a nice result:

The A
The X
The a
Theme
The x

If anything, it would be better to ignore them only between digits, to be able to sort this:

1
1 000 000
10
10 000
10 000 000
100
100 000
1000
	public static void whitespace() {
		List<String> list = new ArrayList<>();
		list.add("The a");
		list.add("The x");
		list.add("Theme");
		list.add("The X");
		list.add("The A");

		Collections.sort(list, new NaturalOrderComparator());
		for (String item : list) {
			System.out.println(item);
		}
		System.out.println("---------");
	}

	public static void whitespaceInNumbers() {
		List<String> list = new ArrayList<>();
		list.add("10 000 000");
		list.add("1 000 000");
		list.add("100 000");
		list.add("10 000");
		list.add("1000");
		list.add("100");
		list.add("10");
		list.add("1");

		Collections.sort(list, new NaturalOrderComparator());
		for (String item : list) {
			System.out.println(item);
		}
		System.out.println("---------");
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant