--- /dev/null
+// plugin Line Sort
+// version 0.0
+// release April 2016
+// author Plugin Fan
+// license GPL v 3.0
+
+// Sorts the selected lines according to a sorting method:
+// - Alt-S - Line Sort
+//
+// Just a simple tool to help when organizing the source code.
+
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.Separator
+
+import static liveplugin.PluginUtil.*
+
+// available sort methods -- the closures are expecting a List of String
+def lineSortMethod = [
+ 'Sort': { it.sort() },
+ 'Sort Case Insensitive': { it.sort(false, String.CASE_INSENSITIVE_ORDER) },
+ 'Sort Numerically': { it.sort { it.findAll(/-?\d*\.?\d+/).collect { it.isInteger() ? it.toInteger() : it.toDouble() } } },
+ 'Sort By Length': { it.sort { it.size() } },
+ 'No Sort, Reverse': { it.reverse() },
+]
+
+// perform the sorting
+def lineSort(project, sorter)
+{
+ runDocumentWriteAction(project) {
+ currentEditorIn(project).with {
+ if (! selectionModel.hasSelection())
+ return
+
+ def text = selectionModel.getSelectedText()
+
+ text = sorter(text.tokenize('\n')).join('\n')
+
+ document.replaceString(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(), text)
+ }
+ }
+}
+
+registerAction('Line Sort', 'alt S') { AnActionEvent event ->
+ def project = event.project
+
+ showPopupMenu(lineSortMethod.collectEntries { type, code -> [type, { lineSort(project, code) } ] }, 'Line Sort', event.dataContext)
+}
Plugins written in [Groovy](http://groovy-lang.org/) script for [IntelliJ IDEA](http://jetbrains.com/idea/) based IDE's that can be enhanced through [LivePlugin](https://github.com/dkandalov/live-plugin) plugin connector.
+* [Line Sort](https://osdn.jp/projects/ii-lp-script/scm/git/ii-lp-script/tree/master/Line%20Sort/) -- Sorts the selected lines according to a sorting method.
* [Move Caret to Word End](https://osdn.jp/projects/ii-lp-script/scm/git/ii-lp-script/tree/master/Move%20Caret%20To%20Word%20End/) -- Moves all carets to the closes word end.
* [PrettyPrint](https://osdn.jp/projects/ii-lp-script/scm/git/ii-lp-script/tree/master/PrettyPrint/) -- Formats the current selection as prettified JSON or XML.