Results 1 to 8 of 8

Thread: selection sort program

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    12

    selection sort program

    just wondering if anyone knew of any selection sort programs. i am looking for one that will open a text file and when i click a button it will sort the names within the text file in alphabetical order...i would really appreciate someone else. Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: selection sort program

    Moved from the CodeBank

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: selection sort program

    Sounds like homework of some sort. Have you tried writing a selection sort algorithm yourself?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: selection sort program

    Why selection sort?

    You are going to have to read all the lines from the text file, sort them, then write them all back out. If the file is just a list of names, with one name per line, then this is a really simple task....until you decide to use some kind of custom sorting algorithm. That step alone will increase the level of difficulty from about three lines to many.

    In any case, you will be sorting an array of strings, so if you have to make your own sorting routine, make one that sorts arrays of strings.
    My usual boring signature: Nothing

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: selection sort program

    Read here. You can even find sample code (written in C++ though)
    http://www.codecodex.com/wiki/index....Selection_sort

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: selection sort program

    Quote Originally Posted by Shaggy Hiker
    Why selection sort?
    Because it's a homework assignment and the teacher specifies to use selection sort....

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: selection sort program

    That's what most questions are, but I thought I'd lead off with a question.

    I've wondered about these homework assignments before, and I will wonder about them again. I can understand the idea that you teach someone how a sort routine works, but why choose one over any other? I guess I can understand why Shell sort and qSort aren't taught, since they are nearly impossible to understand, but why selection sort?
    My usual boring signature: Nothing

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: selection sort program

    http://en.wikipedia.org/wiki/Selection_sort

    Take a shot at it and then post your code if you need help.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width