@cran/lib.vue.ref
Version:
Vue Reactivity Extensions
18 lines (15 loc) • 391 B
text/typescript
import { computed } from "vue";
import { type MaybeWrapped, unwrap } from "../utility";
/**
* @since 0.0.1
* @category Array
* @inheritdoc Array#toSorted
*/
export function useSorted<T> (
values: MaybeWrapped<Array<MaybeWrapped<T>>>,
compareFn: ( a: T, b: T ) => number
) {
return computed(function compute ( ) {
return unwrap(values).map<T>(unwrap).sort(compareFn);
});
}