Simple way to reorder methods of a Java class in IntelliJ?

Solution 1:

You can select a method name and hit: Ctrl+Shift+Up or Ctrl+Shift+Down to move it up and down.

On OS X: Cmd+Shift+Up or Cmd+Shift+Down

Beyond this the Rearranger Plugin lets you move methods around quickly, and even define a standard ordering based on your coding convention.

Solution 2:

IntelliJ has a built in system that allows you to specify how to order your methods. You need to go to Settings (Ctrl + Alt +S) -> Editor -> Code Style -> Java -> Arrangement (tab) and scroll down until you find the icons with methods. There you can manipulate the options to sort them by visibility, or alphabetically, or to keep related ones grouped together. Here is a screenshot of my settings which will order methods automatically by visibility (public, protected, private) and alphabetically (a-z). The blue highlights show the currently selected rules.

enter image description here