I've added a third overload for sort to the type definitions. This definition allows passing in a comparator function.
You can see an example of this in the existing examples. While this works fine, the TypeScript definitions only allowed for passing no args or a boolean in.
You will notice this is a simple comparator function, similar to those used by d3 array in its type definitions. Notice that I've bound the generic variable T here to StackFrame. I'm not 100% sure that's correct. If other things besides StackFrames could be passed as arguments to sort, we can modify it or keep it generic.
I've added a third overload for
sort
to the type definitions. This definition allows passing in a comparator function.You can see an example of this in the existing examples. While this works fine, the TypeScript definitions only allowed for passing no args or a boolean in.
You will notice this is a simple comparator function, similar to those used by d3 array in its type definitions. Notice that I've bound the generic variable
T
here toStackFrame
. I'm not 100% sure that's correct. If other things besidesStackFrame
s could be passed as arguments tosort
, we can modify it or keep it generic.