   @description: "Sort lines alphabetically"
   getNewRows: (rows) ->
     rows.sort()
+
+class SortByNumber extends ChangeOrder
+  @extend()
+  @registerToSelectList()
+  @description: "Sort lines numerically"
+  getNewRows: (rows) ->
+    parseInt = (row) ->
+      Number.parseInt(row) or 0
+
+    _.sortBy(rows, parseInt)

    super

  getNewText: (text) ->
    @input = "\\n" if @input is ''
    regex = ///#{_.escapeRegExp(@input)}///g
    text.split(regex).join("\n")

class ChangeOrder extends TransformString
  @extend(false)
  wise: 'linewise'

  mutateSelection: (selection) ->
    textForRows = swrap(selection).lineTextForBufferRows()
    rows = @getNewRows(textForRows)
    newText = rows.join("\n") + "\n"
    selection.insertText(newText)

class Reverse extends ChangeOrder
  @extend()

  requireInput: true
  input: null
  target: "MoveToRelativeLine"
  keepSplitter: false

  initialize: ->
    @onDidSetTarget =>
