Skip to content

Commit

Permalink
fix sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 1, 2018
1 parent 53f8891 commit 8a1e40b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/model/ICategoricalColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function toCompareCategoryValue(v: ICategory | null) {
return v.value;
}

export const COMPARE_CATEGORY_VALUE_TYPES = ECompareValueType.FLOAT;
export const COMPARE_CATEGORY_VALUE_TYPES = ECompareValueType.FLOAT_ASC;

function findMostFrequent(rows: ISequence<IDataRow>, col: ICategoricalColumn): {cat: ICategory | null, count: number} {
const hist = new Map<ICategory | null, number>();
Expand Down
2 changes: 1 addition & 1 deletion src/model/NumbersColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class NumbersColumn extends ArrayColumn<number> implements INumbe
}

getRawValue(row: IDataRow) {
const r = super.getValue(row);
const r = super.getRaw(row);
return r == null ? [] : r.map((d) => isMissingValue(d) ? NaN : +d);
}

Expand Down
8 changes: 5 additions & 3 deletions src/provider/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export enum ECompareValueType {
FLOAT = 0,
BINARY = 1,
UINT = 2,
STRING = 3
STRING = 3,
FLOAT_ASC = 4,
}

/**
Expand All @@ -34,6 +35,7 @@ export function normalizeCompareValues(vs: ICompareValue[], comparators: {asc: b
switch (d.v) {
case ECompareValueType.BINARY:
case ECompareValueType.UINT:
case ECompareValueType.FLOAT_ASC:
return v == null || isNaN(<number>v) ? missingInt : v;
case ECompareValueType.STRING:
return v == null || v === '' ? missingString : v;
Expand All @@ -49,10 +51,10 @@ export function sortComplex<T extends {sort: ICompareValue[], i: number}>(arr: T
}

const asc = (a: any, b: any) => {
return a < b ? 1 : ((a > b) ? -1 : 0);
return a < b ? -1 : ((a > b) ? 1 : 0);
};
const desc = (a: any, b: any) => {
return a < b ? -1 : ((a > b) ? 1 : 0);
return a < b ? 1 : ((a > b) ? -1 : 0);
};

switch (comparators.length) {
Expand Down

0 comments on commit 8a1e40b

Please sign in to comment.