Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ sort enum members

Is there any way to sort the member variables of an enum alphabetically in IntelliJ? I've been trying a bunch of different settings in the arrangement section but didn't have success. Could anyone maybe help me?

like image 379
Simon04090 Avatar asked Nov 06 '18 15:11

Simon04090


People also ask

Can you sort enum?

By default, the enumeration column is sorted based on the enum flags. So, the display values of that column are different from the normal column sorting. When you want to sort the enumeration column based on the values displayed, you can handle it by changing the CellValueType of the column as string.

How do I sort in Intellij?

To quickly sort lines alphabetically, select them in the editor and choose Edit | Sort Lines from the main menu. Alternatively, you can run this action using the Find Action command (Cmd/Ctrl+Shift+A).


1 Answers

Type Alt+Enter on an enum constant and invoke the sort content intention. This will sort the enum constants in alphabetical order. The intention will only appear if the constants are not alphabetically sorted.

like image 182
Bas Leijdekkers Avatar answered Sep 21 '22 12:09

Bas Leijdekkers