Namespace: tinysort

tinysort

TinySort is a small script that sorts HTML elements. It sorts by text- or attribute value, or by that of one of it's children.

Version:
  • 2.3.6
Author:
License:
  • MIT

Namespaces

charorder
TinySort CharOrder

Methods

<private, static> addCriterium(options)

Adds a criterium

Parameters
Type Argument Description
options Object <optional>

<private, static> addGhost(elmObj) → {elementObject}

Adds a temporary element before an element before reordering.

Parameters
Type Description
elmObj elementObject
Returns
Description
elementObject

<private, static> applyToDOM()

Applies the sorted list to the DOM

<private, static> chunkify(t) → {Array}

Split a string into an array by type: numeral or string

Parameters
Type Description
t string
Returns
Description
Array

<private, static> extend(obj, fns, overwrite) → {Object}

Extend an object

Parameters
Type Argument Default Description
obj Object

Subject.

fns Object

Property object.

overwrite boolean <optional>
false

Overwrite properties.

Returns
Description
Object

Subject.

<private, static> getSortBy(elementObject, criterium) → {String}

Get the string/number to be sorted by checking the elementObject with the criterium.

Parameters
Type Description
elementObject elementObject
criterium criterium
Returns
Description
String
To Do:
  • memoize

<private, static> initSortList()

Creates an elementObject and adds to lists. Also checks if has one or more parents.

<private, static> isString(o) → {boolean}

Test if an object is a string

Parameters
Type Description
o
Returns
Description
boolean

<private, static> loop(array, func)

Traverse an array, or array-like object

Parameters
Type Description
array Array

The object or array

func function

Callback function with the parameters value and key.

<private, static> replaceGhost(elmObjGhost, elm)

Inserts an element before a ghost element and removes the ghost.

Parameters
Type Description
elmObjGhost elementObject
elm HTMLElement

<private, static> sortedIntoFragment() → {DocumentFragment}

Adds all sorted elements to the document fragment and returns it.

Returns
Description
DocumentFragment

<private, static> sortFunction(a, b) → {number}

Sort all the things

Parameters
Type Description
a elementObject
b elementObject
Returns
Description
number

<static> tinysort(nodeList, options) → {Array.<HTMLElement>}

TinySort is a small and simple script that will sort any nodeElement by it's text- or attribute value, or by that of one of it's children.

Parameters
Type Argument Description
nodeList NodeList | Array.<HTMLElement> | String

The nodelist or array of elements to be sorted. If a string is passed it should be a valid CSS selector.

options options <optional>

A list of options.

Returns
Description
Array.<HTMLElement>