Class

Sorter

Sorter(toBeSorted)

consists of methods used to sorft and manipulate the given object
Constructor

# new Sorter(toBeSorted)

Parameters:
Name Type Description
toBeSorted Object pass the object to be sorted
Properties:
Name Type Description
_toBeSorted String the object to be sorted

View Source Sorter/index.ts, line 4

when the object has values that are of any other type than string this will throw an Error
Example
//succeeds
const sorter = new Sorter({
		"key":"value",
		"key1":"value1"
})
// fails
const sorter = new Sorter({
		"key":true
})
// fails
const sorter = new Sorter({
		"key":1
})
// fails
const sorter = new Sorter({
		"key":["anything","other","than","a","normal","string","in","value","will","fail"]
})

Methods

# sort() → {Object}

sorts the object set in the _toBeSorted as per the key length(and value length if key length is same)

View Source Sorter/index.ts, line 36

- returns the fully sorted array sortedArray
Object
Example
const sorter = new Sorter({
		"second":"value",
		"first":"value1",
		"samelength1":"longer value",
		"samelength2":"small value"
})
const output = sorter.sort()
console.log(output)
// {
//		"first":"value1",
//		"second":"value",
//		"samelength2":"small value",
//		"samelength1":"longer value"
// }