4

I'm curious if there is an option to sort the diefferent types like fields, methods, etc by visibility but not by alphabet. I know I can sort the members by using Source -> Cleanup. But it keeps sorting it also alphabeticaly. I just want to sort by visibility and keep the rest of the old ordering.

Example:

public class Person {

    private Person(final Long id, final String name, final String surname) {

    }

    public Person() {
    }

    private Long id;

    private String surname;

    private String name;

    public final static String SOME_CONSTANT = "SOME_CONSTANT";

}

After sorting it should look like this:

public class Person {

    public final static String SOME_CONSTANT = "SOME_CONSTANT";

    private Long id;

    private String surname;

    private String name;

    public Person() {
    }

    private Person(final Long id, final String name, final String surname) {
    }


}

But I get:

public class Person {

    public final static String SOME_CONSTANT = "SOME_CONSTANT";

    private Long id;

    private String name;

    private String surname;

    public Person() {
    }

    private Person(final Long id, final String name, final String surname) {
    }

}
Matthias B
  • 5,523
  • 3
  • 45
  • 47

1 Answers1

2

Pure alphabetical sort is not possible in Eclipse without a plugin. Have you tried setting custom Source->Sort Members options (Preferences->Java->Appearance->Members Sort Order) ?

However you may find some alternatives in this post: Eclipse organize methods in alphabetical order

Community
  • 1
  • 1
Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85