How to order pre-written String[] array elements alphabetically pre-run-time in IntelliJ-IDEA?

Viewed 301

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"};
1 Answers

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.

Related