Expand all

CodeMirrorSortLines

Provides line sorting functionality for CodeMirror.

This allows customization of sorting options via CodeMirrorSortLines#setOptions. See Intl.CollatorOptions for available locale-friendly sorting options.

Example

// This can be made into a user script, default gadget for wiki, etc.
mw.hook( 'ext.CodeMirror.ready' ).add( ( cm ) => {
  // Set sorting options to be case-sensitive and ignore punctuation.
  cm.sortLines.setOptions( { sensitivity: 'case', ignorePunctuation: true } );
} );

Properties

options :Intl.CollatorOptions #

Get the effective sorting options.

Type:

Source:
Get the effective sorting options.

Methods

resetOptions() #

Reset sorting options to defaults.

Source:
Reset sorting options to defaults.

setOptions([options]) #

Set sorting options used by line-sorting commands.

Parameters:

Name Type Attributes Default Description
options Intl.CollatorOptions optional
{}
Source:
Set sorting options used by line-sorting commands.

sortAscending(view) → {boolean} #

Sort selected lines in ascending order.

Parameters:

Name Type Description
view EditorView

Returns:

Type
boolean
Source:
Sort selected lines in ascending order.

sortDescending(view) → {boolean} #

Sort selected lines in descending order.

Parameters:

Name Type Description
view EditorView

Returns:

Type
boolean
Source:
Sort selected lines in descending order.