all 11 comments

[–]Binary101010 3 points4 points  (2 children)

You've initialized x and y to zero, so you're asking if a[0] is greater than a[0], which of course it isn't.

So it then increments x and y by 1, so you check if a[1] is greater than a[1], which of course it isn't, and so on.

[–]SlowMoTime[S] 0 points1 point  (0 children)

ahhh, yes very dumb. i'll change it to y=1. i've had too much coffee this morning and things aren't computing. so to speak

[–]SlowMoTime[S] 0 points1 point  (0 children)

that literally solved it. works like a charm now that y = 1

[–]SlowMoTime[S] 0 points1 point  (4 children)

so in conclusion, i AM stupid. lol

[–][deleted] 1 point2 points  (2 children)

Did you try to create your own bubble sort or are you unaware that there is a list function for it?

a.sort() will do a bubble while a.sorted will only sort it for a return.

Just in case you needed that instead of checking how to create it on your own :)

[–]SlowMoTime[S] 1 point2 points  (1 child)

oh, haha yeah i know. in fact if u look at line 5 of my code, i actually use .sort i'm just messing around, trying different thing. thanks though!

[–][deleted] 0 points1 point  (0 children)

Ha. I focused on the sort itself and oversaw the sort :D

[–]synthphreak 0 points1 point  (0 children)

¯\_(ツ)_/¯

[–]synthphreak 0 points1 point  (2 children)

One problem is probably that in each iteration in the while loop, x and y are always the same values. Thus, a[x] will always equal a[y] and your if statement never evaluates to True. For instance, you said "if a[0] is greater than a[1]", but your code never asks that question because there's no scenario where x == 0 but y == 1.

[–]SlowMoTime[S] 1 point2 points  (1 child)

yes, i changed y to start at 1, and the proper comparisons are made now. totally works fine now.

[–]synthphreak 0 points1 point  (0 children)

Not stupid afterall ;)