Sorting lines of text alphabetically with Sublime Text 3

I needed to sort hundreds of lines of text in a PHP file the other day. It was a large array of strings, and I wanted to alphabetize it so I could easily see if a specific string was already present.

Some time ago, I did this with a script. It looped through the array, sorted it, and output the results. I then copied them back into the file manually.

Of course, now I have Sublime Text. "There has to be a plugin for that," I thought. But there wasn't—because it's built into the core. Even better.

So, if you're looking for a quick way to alphabetize multiple lines of text in Sublime Text, just go to Edit > Sort Lines or press F5.

Author avatar

About the author

Creator of Surreal CMS, Postleaf, and other web things.

Need to get in touch? Catch me on Twitter.