(Feb-22-2021, 08:54 AM)Gribouillis Wrote: Not a numpy expert here, but this seems to reverse all the axis simultaneouslyThanks for your help. I got the following answers with some help from Stack Overflow and another source:
import numpy as np random_array = np.round(10 * np.random.rand(5, 4, 4)) sorted_array = np.sort(random_array,axis=1) a = sorted_array.reshape(sorted_array.size) reversed_array = a[::-1].reshape(sorted_array.shape) print('Sorted Array:') print(sorted_array,'\n') print('Reversed Array:') print(reversed_array)
[:,::-1] reverses 2D array rows, [:,::-1,:] reverses 3D array columns, [:,:,::-1] reverses 3D array rows, [:,:,::-1,:] reverses 4D array columns, [:,:,:,::-1] reverses 4D array rows
Gribouillis, I see that you're a Moderator. When I view threads and posts, under my username, Jeremy7, are the words "Programmer named Tim," but my name is not Tim. Respectfully request "Programmer named Tim" be removed. Thanks!