Sort SolutionArray by column ``col``. :param col: Column that is used to sort the SolutionArray. :param reverse: If True, the sorted list is reversed (descending order).
(self, col, reverse=False)
| 830 | self._indices.append(len(self._indices)) |
| 831 | |
| 832 | def sort(self, col, reverse=False): |
| 833 | """ |
| 834 | Sort SolutionArray by column ``col``. |
| 835 | |
| 836 | :param col: Column that is used to sort the SolutionArray. |
| 837 | :param reverse: If True, the sorted list is reversed (descending order). |
| 838 | """ |
| 839 | if len(self.shape) != 1: |
| 840 | raise TypeError("sort only works for 1D SolutionArray objects") |
| 841 | |
| 842 | indices = np.argsort(getattr(self, col)) |
| 843 | if reverse: |
| 844 | indices = indices[::-1] |
| 845 | states = [self._get_state(ix) for ix in indices] |
| 846 | for loc in range(self.size): |
| 847 | self._set_state(loc, states[loc]) |
| 848 | |
| 849 | for k in self.extra: |
| 850 | v = self._get_component(k) |
| 851 | self._set_component(k, v[indices]) |
| 852 | |
| 853 | def equilibrate(self, *args, **kwargs): |
| 854 | """ See `ThermoPhase.equilibrate` """ |