Sorting of an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chittaranjan
    New Member
    • Sep 2006
    • 51

    Sorting of an array

    Hi All,

    I want to sort an array which is having data like below:

    @array = {1 aaa bbb ccc 4 sss ddd fff};

    In this array above I have two arrays that one is from 1 to ccc and another is from 4 to fff. I want to sort in such a way which will out put me like:

    @array = {1 aaa bbb ccc 2 sss ddd fff};

    If any kind of solutions are there then please suggest me I am seeking for this soon. If possible then please post some sample codes.

    Thanks and Regards,
    Chittaranjan.
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Hi Chittaranjan,

    What have you tried so far?

    - Miller

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      the array is already sorted, so the question makes no sense. Plus it is not two arrays, it is just one array. Explain your situation better and post the code you have been trying. Is this school work? That array looks contrived.

      Comment

      • Chittaranjan
        New Member
        • Sep 2006
        • 51

        #4
        Originally posted by KevinADC
        the array is already sorted, so the question makes no sense. Plus it is not two arrays, it is just one array. Explain your situation better and post the code you have been trying. Is this school work? That array looks contrived.
        Thanks for your quick response but this is not a school work I just wanted to say that I have an array which is a combination of two different arrays let me explain the entire situation:
        I have one tab separated array $tData[$i] = {1 name description number etc}
        and one more that is $tAddr[$j] = {xyz address city etc}
        I am joining these two arrays like $tline[$i] = $tData[$i] . $delim . $tAddr[$j];

        My arrays I have shown above are containing multiple similar values as shown above so after joining I am getting the resulting array as
        $tline[$i] = {1 name description number etc xyz address city etc} as you can see I have on $i that increments upto some length I have given.

        So my question is that If I will get an array like
        $tline[$i] = {1 name description number etc xyz address city etc 4 name description number etc xyz address city etc}
        Here I want to sort the numbers in bold tha should look like
        $tline[$i] = {1 name description number etc xyz address city etc 2 name description number etc xyz address city etc}

        Hope this will help me to get some help from experts like you...

        Thanks again,
        Chittaranjan.

        Comment

        • Chittaranjan
          New Member
          • Sep 2006
          • 51

          #5
          However Thanks a lot to you all for a great help in a great manner I am able to figure out my solution.

          Thanks,
          Chittaranjan :)

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            Consider we offered you no real help, it's nice of you to thank us.

            Comment

            Working...