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 9253857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:19:25+00:00 2026-06-18T11:19:25+00:00

I am trying to perform bubble sort is Unix shell script. Why is my

  • 0

I am trying to perform bubble sort is Unix shell script. Why is my code not working?

a=(10 8 20 25 12)

for ((i=0;i<5;i++))
do
 for((j=0;j<5;j++))
 do
if ((${a[j]} > ${a[$((j+1))]}))
then
  v=${a[$j]}
  a[$j]=${a[$((j+1))]}
  a[$((j+1))]=$v
    fi
 done
done
    echo ${a[*]}
    echo "end..."
  • 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-18T11:19:27+00:00Added an answer on June 18, 2026 at 11:19 am

    I guess this is homework. therefore I don’t give codes, just point out the errors in your codes:

    for((j=0;j<5;j++)) then read a[j+1], here would be problem because when j=4, j+1 doesn’t exist

    fix that, your program will sort.

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

Sidebar

Related Questions

I am trying to perform a cURL request (either directly from shell or via
I'm trying to perform the following query in LLBL and I'm not having much
I'm trying to perform a really simple summation in MATLAB. Here is my code:
I'm trying to perform a simple insertion sort in C# but I don't know
Trying to perform a single boolean NOT operation, it appears that under MS SQL
I'm trying to perform a bitwise NOT in SQL Server. I'd like to do
Trying to perform a pull from a remote repository, however the relevant code is
I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using
Im trying to perform a mod rewriting to my web site. And I used
I am trying to perform an automatic login when the user clicks a link

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.