Skip to content

Instantly share code, notes, and snippets.

@t-mart
Created September 11, 2019 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-mart/5f400fc7baeab7033dbd8765126863f9 to your computer and use it in GitHub Desktop.
Save t-mart/5f400fc7baeab7033dbd8765126863f9 to your computer and use it in GitHub Desktop.
# create a list of 2d indices of A in decreasing order by the size of the
# (real) entry of A that they index to
def sortedIndices(A):
indexList = [(i,j) for i in range(A.shape[0]) for j in range(A.shape[1])]
indexList.sort(key=lambda x: -A[x])
return np.array(indexList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment