8 examples of 'datatable sorting false' in JavaScript

Every line of 'datatable sorting false' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
132public get isSorting() { return this.header && this.header.colSorting; }
149_isSorting(columnIndex, sortColumn) {
150 return columnIndex === sortColumn;
151}
90function quickSort(left, right) {
91 if (left < right) {
92 // QuickSort's effectiveness depends on its ability to partition the
93 // sequence being sorted into two subsequences of roughly equal length:
94 // by halving the length at each recursion level, the subproblems get
95 // smaller faster. To get a good partition, we must choose a pivot value
96 // that is close to the median of the values in the sequence: by
97 // definition, half of the values will fall before the median, half
98 // after it.
99 // If the sequence is already mostly sorted, then choosing the first or
100 // last value as the pivot is probably as far from the median as you
101 // could possibly get; this is a "pessimal", not optimal, choice.
102 // Choosing the middle value as the pivot is likely to be much closer to
103 // the median.
104 const pivot = (left + right) >> 1;
105 const partitionIndex = partition(pivot, left, right);
106
107 // Sort left and right
108 quickSort(left, partitionIndex - 1);
109 quickSort(partitionIndex + 1, right);
110 }
111}
57isSortAsc() {
58 return this.currentSorting.dir === 1;
59}
128setSorting(sorting: DataSorting): void {
129 this._sorting = sorting;
130
131 if (sorting && sorting.key) {
132 this._rows.sort((a: DataRow, b: DataRow) => {
133 let left = a.getValue(sorting.key);
134 if (left) {
135 left = (left instanceof Date) ? left.valueOf().toString() : left.toString();
136 } else {
137 left = '';
138 }
139
140 let right = b.getValue(sorting.key);
141 if (right) {
142 right = (right instanceof Date) ? right.valueOf().toString() : right.toString();
143 } else {
144 right = '';
145 }
146
147 return sorting.direction === 'asc'
148 ? left.localeCompare(right)
149 : right.localeCompare(left);
150 });
151 }
152}
25isSorting(field) {
26 return this.$scope.sortField() === this.getSortName(field);
27}
363private sortRows(rows: Row[]): Row[] {
364 if (!this.sortingSettings.length) {
365 return rows;
366 }
367
368 let sortings = this.sortingSettings.slice();
369 return rows.slice().sort((a, b) => {
370 let res;
371 for (let i = 0, len = sortings.length; i < len; i++) {
372 let s = sortings[i];
373 let accessor = functor(s.accessor);
374 res = s.comparer(accessor(a), accessor(b));
375 if (res !== 0) return res;
376 }
377 return res;
378 });
379}
41sortData(data: any[], sortBy: string, sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Ascending): any[] {
42 if (sortBy) {
43 data = Array.from(data); // Change the array reference to trigger OnPush and not mutate original array
44 data.sort((a: any, b: any) => {
45 const compA: any = a[sortBy];
46 const compB: any = b[sortBy];
47 let direction: number = 0;
48 if (!Number.isNaN(Number.parseFloat(compA)) && !Number.isNaN(Number.parseFloat(compB))) {
49 direction = Number.parseFloat(compA) - Number.parseFloat(compB);
50 } else {
51 if (compA < compB) {
52 direction = -1;
53 } else if (compA > compB) {
54 direction = 1;
55 }
56 }
57 return direction * (sortOrder === TdDataTableSortingOrder.Descending ? -1 : 1);
58 });
59 }
60 return data;
61}

Related snippets