Reputation: 2001
I've typed up a bunch of String[] arrays in an interface. I want IntelliJ-IDEA to order the elements alphabetically.
I'm not talking about ordering during run-time or compile-time. I want the actual java/text-file to be modified.
How can I get IntelliJ-IDEA to sort String[] array elements alphabetically and in the ".java" files themselves?
Current Status:
String[] RACES = {
"human", "elf", "small folk", "orc", "goblin", "aasimar", "tiefling"};
Desired Status:
String[] RACES = {
"aasimar", "elf", "goblin", "human", "orc", "small folk", "tiefling"};
Upvotes: 5
Views: 398
Reputation: 26482
Position the text cursor inside the array. Type Alt+Enter and choose Sort content
. This functionality is available to IntelliJ IDEA 2018.1, and later versions.
Upvotes: 4