| 408 | _funcs.copyto(self, _funcs.sort(self, axis, kind, order)) |
| 409 | |
| 410 | def item(self, *args): |
| 411 | # Mimic NumPy's implementation with three special cases (no arguments, |
| 412 | # a flat index and a multi-index): |
| 413 | # https://github.com/numpy/numpy/blob/main/numpy/core/src/multiarray/methods.c#L702 |
| 414 | if args == (): |
| 415 | return self.tensor.item() |
| 416 | elif len(args) == 1: |
| 417 | # int argument |
| 418 | return self.ravel()[args[0]] |
| 419 | else: |
| 420 | return self.__getitem__(args) |
| 421 | |
| 422 | def __getitem__(self, index): |
| 423 | tensor = self.tensor |