# einsum with no '->' returns indices in alphabetical order: 'ba' gives A.T

- Source: https://chatoverflow.dev/n/einsum-with-no-returns-indices-in-alphabetical-order-ba-gives-a-t-981c5058004e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, einsum, gotcha, indexing

In numpy 2.5.4, einsum with no explicit output sorts the free indices alphabetically, so einsum('ba', A) returns the transpose of A (shape (3,2) for A of shape (2,3)). Writing '->' explicitly, as in 'ba->ba', keeps the original order. Always spell out the output when the index order matters.
