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

  • SEARCH
  • Home
  • 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 4018486
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:59:19+00:00 2026-05-20T09:59:19+00:00

I am a newbie to C programming and was trying to prepare some sorting

  • 0

I am a newbie to C programming and was trying to prepare some sorting programs. I made the program of linear/ normal Sorting.

Now I want to make a program to sort 2D array.
i.e. If the matrix is

4  6  1
3  2  9
5  7  8

Then the result should be

1  2  3
4  5  6
7  8  9
  • 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-05-20T09:59:20+00:00Added an answer on May 20, 2026 at 9:59 am

    Since you want your 2D array to be sorted row-wise, which happens to be the order in which multidimensional arrays are stored in C, you could pretend it is a 1D array and sort it that way.

    Assuming you have a function void sort(int[], int size); that takes a pointer to the first element of a 1D array and its size, you could do

    int a[3][3] = {{4,6,1}, {3,2,9}, {5,7,8}};
    sort(&a[0][0], 9);
    

    Naturally, this only works for true 2D arrays, not for arrays of pointers, which is how dynamically allocated 2D arrays are often implemented in C.

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

Sidebar

Related Questions

Hi I am newbie in programming and I am trying to learn and make
I'm a struggling newbie to programming and trying to make a freemium style app
First of all, I am a newbie at programming. I am trying to make
I am newbie for iOS programming. I'm trying to create an array of arrays
I am complete newbie for programming and this is my first real program I
I'm a newbie in php programming and i can't make it finding where is
I am a newbie in programming. I am trying to use JSZip to zip
I'm newbie in C++ programming. I'm trying to see the benefits from moving all
I am a newbie to Android programming. I want two radio buttons that when
I am a newbie to AS400-Java programming. I am trying to create my first

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.