Skip to content

Mooyi07/Array_sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Array Sorting Program

πŸ“Œ Description

This Java program takes an array of numbers as input and sorts them in ascending order using a basic Bubble Sort algorithm. Users specify the number of elements in the array and input their values, which are then sorted and displayed.

πŸ›  Features

  • Accepts user input for the number of elements.
  • Reads multiple integers from the user.
  • Displays the original array before sorting.
  • Sorts the array in ascending order (modifiable for descending order).
  • Prints the sorted array.

πŸ“‚ File Structure

  • Array_Sort.java – Contains the implementation for sorting an array.

πŸš€ Usage

  1. Compile the Java file:
    javac Array_Sort.java
  2. Run the program:
    java Array_Sort
  3. Enter the number of elements and the array values:
    Enter number of arrays: 5
    Input 5 number/s:
    8 3 7 1 9
    
  4. Example Output:
    Original Array: 8, 3, 7, 1, 9
    Sorted Array: 1, 3, 7, 8, 9
    

πŸ“ Explanation

  1. The program prompts the user to input the size of the array.
  2. It then collects integer values into an array.
  3. The Bubble Sort algorithm is used to arrange the numbers in ascending order.
  4. The sorted array is displayed as output.
  5. To switch to descending order, simply change the comparison operator (> to <) in the sorting loop.

πŸ“œ License

This project is open-source and free to use.

About

Algorithm for sorting arrays in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages