(options?: { ascending?: boolean, inplace?: boolean })
| 826 | */ |
| 827 | sortValues(options?: { ascending?: boolean, inplace?: boolean }): Series |
| 828 | sortValues(options?: { ascending?: boolean, inplace?: boolean }): Series | void { |
| 829 | const { ascending, inplace, } = { ascending: true, inplace: false, ...options } |
| 830 | |
| 831 | let sortedValues = []; |
| 832 | let sortedIndex = [] |
| 833 | const rangeIdx = utils.range(0, this.index.length - 1); |
| 834 | let sortedIdx = utils.sortArrayByIndex(rangeIdx, this.values, this.dtypes[0]); |
| 835 | |
| 836 | for (let indx of sortedIdx) { |
| 837 | sortedValues.push(this.values[indx]) |
| 838 | sortedIndex.push(this.index[indx]) |
| 839 | } |
| 840 | |
| 841 | if (ascending) { |
| 842 | sortedValues = sortedValues.reverse(); |
| 843 | sortedIndex = sortedIndex.reverse(); |
| 844 | } |
| 845 | |
| 846 | if (inplace) { |
| 847 | this.$setValues(sortedValues as ArrayType1D) |
| 848 | this.$setIndex(sortedIndex); |
| 849 | } else { |
| 850 | const sf = new Series(sortedValues, { |
| 851 | index: sortedIndex, |
| 852 | dtypes: this.dtypes, |
| 853 | config: this.config |
| 854 | }); |
| 855 | return sf; |
| 856 | |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | |
| 861 | /** |
no test coverage detected