Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8067645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:23:36+00:00 2026-06-05T12:23:36+00:00

For my software major work I have to create a program. In summary, the

  • 0

For my software major work I have to create a program. In summary, the high scores list needs to be sorted before it can be written to file. To do this, I am using a bubble sort and I can’t use the inbuilt sort function. The text file that the data is being read from is stored in a nested list. The text file looks like this:

NameOne
10
NameTwo
15
NameThree
9

This is the bubble sort code I have but does not work:

b_not_sorted = True
while b_not_sorted:
    counter = 0
    b_not_sorted = False
    for counter in range(len(highest_scores) - 1):
        if highest_scores[counter] < highest_scores[counter + 1]:
            b_not_sorted = True
            highest_scores[counter], highest_scores[counter+1] = highest_scores[counter+1], highest_scores[counter]
        counter = counter + 1

I need the scores to be sorted from highest to lowest. Any help would be greatly appreciated and you will be credited appropriately in my program credits :). Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:23:40+00:00Added an answer on June 5, 2026 at 12:23 pm

    Here’s a hint:

    Check how many times your outer while loop is running. It should be running more than once, correct? What will always happen that causes the loop to exit, no matter what?

    Try going through the code line by line and seeing what happens at every point.

    The statement b_not_sorted = False at the end of the outer loop results in the outer loop exiting after executing only once. You need to move that statement to another part of your code. Try changing the name of b_not_sorted to I_still_need_to_go_through_the_list in your head:

    Obviously in the first line:

    while I_still_need_to_go_through_the_list:
    

    it should be True, since you haven’t gone over the list at all. You don’t know if it’s in order or not.

    and after the line:

    if highest_scores[counter] < highest_scores[counter + 1]:
    

    Of course then we still need to make another pass, since we just made a change to the list and need to make sure no further changes are needed.

    But what if no changes are made? I_still_need_to_go_through_the_list should be False then. Hmmm. If we put I_still_need_to_go_through_the_list = False right before the for loop, then it will be False unless we make changes to the list, which is exactly what we want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a parental control software program for my company, but have
In large and complex software products managing configurable settings becomes a major pain. Two
The software group I currently work in has recently decided to start documenting our
For software development one often needs images. But when I start working on an
My software is written in Qt 4.4.2 using XCode on Mac OS X 10.5.
what software can help me to unwar a war file and get the java
A software application that I'm working on needs to be able to assign tasks
I am a software engineer and i work in VC++, C++ in WIndows OS.
We have a software package which is about 16 years old. It's gone through
How and with what software do major television companies display on-screen graphics during their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.