Python Forum
Question about Python Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about Python Code
#6
You are swapping values.
temp = aList[3] #for example, save the value in the 4th position of aList in a temporary variable
aList[3] = aList[3+1] #move the value in the 5th position to the 4th position
alist[3+1] = temp #now put the value that was in the 4th position into the 5th position.

It's called a bubble sort. Here are some related links. The Wikipedia entry is perhaps a tad complex.
https://www.geeksforgeeks.org/bubble-sort/
https://en.wikipedia.org/wiki/Bubble_sort
Reply


Messages In This Thread
Question about Python Code - by Than999 - Nov-04-2019, 06:39 PM
RE: Question about Python Code - by Axel_Erfurt - Nov-04-2019, 07:08 PM
RE: Question about Python Code - by jefsummers - Nov-04-2019, 08:34 PM
RE: Question about Python Code - by Than999 - Nov-04-2019, 10:14 PM
RE: Question about Python Code - by Than999 - Nov-04-2019, 11:36 PM
RE: Question about Python Code - by jefsummers - Nov-05-2019, 02:59 AM
RE: Question about Python Code - by Than999 - Nov-05-2019, 07:02 PM
RE: Question about Python Code - by ichabod801 - Nov-05-2019, 07:10 PM
RE: Question about Python Code - by Than999 - Nov-05-2019, 07:32 PM
RE: Question about Python Code - by jefsummers - Nov-05-2019, 08:30 PM
RE: Question about Python Code - by Than999 - Nov-05-2019, 11:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Use Python for solving the following physics question. Python Code required ishahid 8 3,866 Dec-18-2019, 06:59 AM
Last Post: akashraj128

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020