Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: bubble sort and selection sort on strings

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default bubble sort and selection sort on strings

    dfseresresrere
    Last edited by Sir Saula; July 10th, 2010 at 10:09 PM.
    Thanks,
    Saula

    Need more help?
    http://homeworkjava.com/


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,299
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: bubble sort and selection sort on strings

    The output you show is sorted with case sensitivity. 'Z' comes before 'a'

    Show what you think the order should be.

    Please post links to other forums this is posted on.

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: bubble sort and selection sort on strings

    Example output

    You display:
    As entered
    0:a:apple
    1:a:Apple
    2:z:Zone
    3:a:apple
    Bubble Sorted
    0:a:apple
    1:a:Apple
    3:a:apple
    2:z:Zone
    Selection Sorted
    1:a:Apple
    0:a:apple
    3:a:apple
    2:z:Zone


    I think that was just how the format to be but i am not certain...is there a code that can generate that output
    Thanks,
    Saula

    Need more help?
    http://homeworkjava.com/

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,299
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: bubble sort and selection sort on strings


  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,299
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: bubble sort and selection sort on strings

    See answers on the other forum.

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: bubble sort and selection sort on strings

    Uppercase letters by default will always get sorted ahead of lower case letters (when considering case) because their underlying representation in Unicode puts upper case letters before lower case letters.

    If you want to sort the string such that B comes before b but B comes after a, you will need to implement the comparison method yourself.

Similar Threads

  1. Javascript Bubble Sort
    By Fidelacchius in forum What's Wrong With My Code?
    Replies: 17
    Last Post: May 24th, 2010, 05:43 PM
  2. bubble sort timer problem
    By JavaNoob82 in forum Algorithms & Recursion
    Replies: 1
    Last Post: March 12th, 2010, 09:22 AM
  3. can't figure out how to sort an array.
    By etidd in forum Java Theory & Questions
    Replies: 2
    Last Post: February 6th, 2010, 03:07 PM
  4. Hibbard Shell Sort
    By biglandphil in forum Algorithms & Recursion
    Replies: 3
    Last Post: November 12th, 2009, 10:14 PM
  5. Help with Sort arrays
    By drk in forum Collections and Generics
    Replies: 5
    Last Post: September 6th, 2009, 03:48 AM