Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 3356x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 1152x 3330x 3330x 3330x 1152x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 1150x 1150x 1150x 1150x 1150x 130x 130x 130x | /*!
* WikiLambda Vue editor: Sorting utility functions
*
* @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
* @license MIT
*/
'use strict';
const sortUtils = {
/**
* Locale-aware label sort comparator.
* Sorts labels using a language code with base sensitivity and numeric sorting.
* (case-insensitive, accent-insensitive, numeric sorting).
*
* Handles numeric sorting correctly for Z{number}K{number} (e.g., Z23723K1, Z23723K2, ..., Z23723K9, Z23723K10).
*
* @param {string} langCode - Language code (e.g., 'en', 'es')
* @param {string} a - First label to compare
* @param {string} b - Second label to compare
* @return {number} Negative if a < b, positive if a > b, 0 if equal
*/
sortLabelByLocale: function ( langCode, a, b ) {
return a.localeCompare( b, langCode, { sensitivity: 'base', numeric: true } );
},
/**
* Creates a sort comparator function for objects with a specific property.
* Useful for sorting arrays of objects by a property value.
*
* @param {Function} comparator - Base comparator function (e.g., sortLabelByLocale)
* @param {string|Function} property - Property name or function to extract value from object
* @return {Function} Comparator function for objects
*/
createPropertyComparator: function ( comparator, property ) {
return ( a, b ) => {
const aValue = typeof property === 'function' ? property( a ) : a[ property ];
const bValue = typeof property === 'function' ? property( b ) : b[ property ];
return comparator( aValue, bValue );
};
},
/**
* Creates a locale-aware label sort comparator for objects.
*
* @param {string} langCode - Language code
* @param {string|Function} property - Property name or function to extract label from object
* @return {Function} Comparator function for objects with labels
*/
createLabelComparator: function ( langCode, property = 'label' ) {
return sortUtils.createPropertyComparator(
( a, b ) => sortUtils.sortLabelByLocale( langCode, a, b ),
property
);
}
};
module.exports = sortUtils;
|