Could somebody help sorting matrix elements in non-decreasing order?

This is a discussion on Could somebody help sorting matrix elements in non-decreasing order? within the C Programming forums, part of the General Programming Boards category; Dear all, I'm a beginner of C programming, and I've asked to sort N x N matrix of integers randomly ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    Smile Could somebody help sorting matrix elements in non-decreasing order?

    Dear all,

    I'm a beginner of C programming, and I've asked to sort N x N matrix of integers randomly generated
    in non-decreasing order such like...

    1 5 9 13 25
    2 6 11 16 27
    3 7 14 18 28
    4 8 15 21 30
    10 11 20 23 50

    At the first glance, I thought it's just an extension of sorting algorithms in 1-dimension array, but it becomes rather clear that it's far more than that xD

    I would appreciate if somebody can help me working with this monster...


    Thanks
    Last edited by cosmos8294; 05-26-2011 at 08:30 PM. Reason: snip email address

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    Well if you only have to sort within a row (which your example implies), then it really is just a simple sort, repeated for each row of the matrix.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting ABC order
    By rodrigorules in forum C++ Programming
    Replies: 4
    Last Post: 02-22-2010, 01:37 AM
  2. understanding projection matrix elements
    By Anddos in forum Game Programming
    Replies: 3
    Last Post: 07-26-2009, 04:35 PM
  3. sort elements of 2D matrix by 1st column reference
    By cfdprogrammer in forum C Programming
    Replies: 12
    Last Post: 05-04-2009, 04:26 PM
  4. how to initialize a char matrix with empty elements?
    By kobra_swe in forum C Programming
    Replies: 3
    Last Post: 08-22-2006, 06:28 AM
  5. printing array elements in ascending order
    By galmca in forum C Programming
    Replies: 29
    Last Post: 10-25-2004, 12:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21