import { ExecuteAFM as AFM } from "@gooddata/typings"; import { IRandomDataResult } from "./dataResult"; export interface ISortAction { sortIndex: number; direction: AFM.SortDirection; type: "headers" | "data"; } export interface ISortEntry { originalIndex: number; values: any[]; } /** * This is thrown in case sort locators are not valid. */ export declare class SortDefinitionError { private readonly message; constructor(message: string); getMessage(): string; } /** * Fun sort applies sortItems from resultSpec to headers and data. The sorting works as follows: * * 1. Create sort actions = definitions of what to sort on; these are derived from sort items and reflect * multi-dimensional nature of sort. The actions specify index of row or column to sort on. * * 2. Sort actions are performed by dimension - row sorting is done first, then column sorting. The sort is done * in multiple steps: * * 1. Extract sort entries = values from result to sort by + original index of the values * 2. Sort the entries * 4. Obtain sort vectors = current entry index => original index in the entry * 5. Apply sort vectors on both data and headers * * This sorting code seems to be able to deal with any combination that the real backend can accept. */ export declare class FunSort { private readonly result; constructor(result: IRandomDataResult); run(sortItems: AFM.SortItem[]): void; private createSortActions; /** * This method evaluates measure sort item locators. * * @param sortItem measure sort item to evaluate * @param dimension dimension in which to evaluate (ROW/COL) * @returns index within the dimension to sort by */ private findSortIndex; private sortVector; private sort; private sortArray; } export declare type SortEntryComparator = (a: ISortEntry, b: ISortEntry) => number; export declare function createComparator(sortItems: ISortAction[]): SortEntryComparator;