I'm confused as to why this bubble sort I'm implementing on a numpy array is setting all items to one of the items (I have no idea which one as array is too big)
the data type is of
...
[[1128 1026 1192 1023]]
[[ 771 195 858 196]]
[[ 953 1799 955 1738]]]
when I have an array of int, this same algorithm sorts it perfectly,
g = [i for i in range(10)]
for i in range(0,len(g)):
for j in range(0,len(g)):
if(g[i]>g[j]):
cnt = g[i]
g[i] = g[j]
g[j] = cnt
I presume my issue is that I do not understand multidimensional numpy array element assigment, please explain why this breaks:
lines = cv2.HoughLinesP(edges, rho, theta, threshold, np.array([]),
min_line_length, max_line_gap)
sort by an 2nd element of each item
for i in range(0,len(lines)):
for j in range(0,len(lines)):
if(lines[i][0][1]<lines[j][0][1]):
cnt = lines[i][0]
lines[i][0] = lines[j][0]
lines[j][0] = cnt[/CODE]
now the array is
[[[ 738 1831 867 1831]]
...
[[ 738 1831 867 1831]]
[[ 738 1831 867 1831]]
[[ 738 1831 867 1831]]]
why? Any help appreciated.
cnt = lines[i][0].copy()andlines[i][0] = lines[j][0].copy()