/home/caleb/ASDV-Java/Exams/Exam2_mvn_Practice_CalebFontenot/src/main/java/com/calebfontenot/exam2_mvn_practice_calebfontenot/SortCharsInString.java

    /*
     * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
     * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
     */
    package com.calebfontenot.exam2_mvn_practice_calebfontenot;

    /**
     *
     * @author caleb
     */
    public class SortCharsInString {

        public static String sort(String s)
        {
            // Read string chars, and sort them
            char array[] = s.toCharArray();
            char temp;
            int i = 0;
            while (i < array.length) {
                int j = i + 1;
                while (j < array.length) {
                    // Compare each char, if one is larger, swap them
                    if (array[j] < array[i]) {
                        temp = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                    }
                    j += 1;
                }
                 i += 1;
            }

            // Rebuild string
            String rebuiltString = "";
            for (char charInArray : array) {
                rebuiltString += charInArray;
            }
            return rebuiltString;
        }

        public static void main(String[] args)
        {
            java.util.Scanner input = new java.util.Scanner(System.in);
            System.out.print("Enter a string: ");
            String s = input.nextLine();
            System.out.println("Sorted string is " + sort(s));
        }
    }