}
Object.assign(opts, SORT_ORDER_MAP[this.sortOrder]);
- let _doingTitleSort = false;
- if (this.sortOrder === 'title_asc' ||
- this.sortOrder === 'title_desc') {
- // if we're going to sort by title, we'll need
+ let _doingClientSort = false;
+ if (this.sortOrder === 'title_asc' ||
+ this.sortOrder === 'title_desc' ||
+ this.sortOrder === 'author_asc' ||
+ this.sortOrder === 'author_desc' ||
+ this.sortOrder === 'publisher_asc' ||
+ this.sortOrder === 'publisher_desc') {
+ // if we're going to sort by an attribute, we'll need
// to actually fetch LI attributes so that we can
// do a client-side sorting pass that ignores
- // articles
- _doingTitleSort = true;
+ // articles and attempts international collation
+ _doingClientSort = true;
opts['flesh_attrs'] = true;
} else {
// not doing a title sort, so we can rely on
null,
opts
).toPromise().then(resp => {
- if (_doingTitleSort) {
+ if (_doingClientSort) {
const sortOrder = this.sortOrder;
const liService = this.liService;
function _compareLIs(a, b) {
// Alerts the user has already confirmed are OK.
alertAcks: {[id: number]: boolean} = {};
+ naturalCollator = new Intl.Collator(undefined,
+ {numeric: true, sensitivity: 'base', ignorePunctuation: true});
+
constructor(
private idl: IdlService,
private net: NetService,
return a_val === b_val ? 0 :
a_val === null ? 1 :
b_val === null ? -1 :
- a_val > b_val ? 1 :
- a_val < b_val ? -1 : 0;
+ this.naturalCollator.compare(a_val, b_val);
}
// Given a line item, get its sort key