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

LuminousNutria :

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"};
Bas Leijdekkers :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=69491&siteId=1