Sorting Array from Higest to Lowest












-5















/**
* @param args the command line arguments
*/
public static void main(String args) {
int x;
x= new int [3];
x[0]=4;
x[1]=1;
x[2]=2;
x[3]=3;
x=sortArray (x);
System.out.println (x[2]);
}

public static int indexOfMaxInRange(int A, int i){
int maxIndex=A[0];
while (i < A.length) {
if (A[i]>maxIndex){
maxIndex= A[i];
}
i++;
}
return maxIndex;
}

public static int swapElement (int A,int i1,int i2) {
int i1value=A[i1];
int i2value=A[i2];
A[i1]=A[i2value];
A[i2]=A[i1value];
return A;
}

public static int sortArray (int A) {
for (int i = 0; i < A.length; i++) {
int x=indexOfMaxInRange (A,i);
swapElement (A,x,i);
}
return A;
}


This keeps on returning on with an error.
I can't seem to find what's wrong with my program.
The objective of the program is to sort an array highest from lowest.










share|improve this question

























  • You really should say what the error is, but it looks like an index out of range error in your swapElement method, because you're using the value in the array as the index. Also note your algorithm is O(n^2) because you're iterating from the start of the sequence for every element of the sequence.

    – Elaskanator
    Nov 20 '18 at 22:56








  • 1





    Hi there, welcome to Stack Overflow. You've gotten a couple downvotes - probably because questions like "why isn't this code working" should include a clear problem definition: what's going wrong, including any errors or erroneous output, along with the minimum complete example of code necessary to reproduce the problem. Check out the how do I write a good question? page and consider editing your question :)

    – MyStackRunnethOver
    Nov 20 '18 at 22:56













  • You probably should include whats going wrong, and where you suspect the error to be

    – Washcloth
    Nov 24 '18 at 0:15
















-5















/**
* @param args the command line arguments
*/
public static void main(String args) {
int x;
x= new int [3];
x[0]=4;
x[1]=1;
x[2]=2;
x[3]=3;
x=sortArray (x);
System.out.println (x[2]);
}

public static int indexOfMaxInRange(int A, int i){
int maxIndex=A[0];
while (i < A.length) {
if (A[i]>maxIndex){
maxIndex= A[i];
}
i++;
}
return maxIndex;
}

public static int swapElement (int A,int i1,int i2) {
int i1value=A[i1];
int i2value=A[i2];
A[i1]=A[i2value];
A[i2]=A[i1value];
return A;
}

public static int sortArray (int A) {
for (int i = 0; i < A.length; i++) {
int x=indexOfMaxInRange (A,i);
swapElement (A,x,i);
}
return A;
}


This keeps on returning on with an error.
I can't seem to find what's wrong with my program.
The objective of the program is to sort an array highest from lowest.










share|improve this question

























  • You really should say what the error is, but it looks like an index out of range error in your swapElement method, because you're using the value in the array as the index. Also note your algorithm is O(n^2) because you're iterating from the start of the sequence for every element of the sequence.

    – Elaskanator
    Nov 20 '18 at 22:56








  • 1





    Hi there, welcome to Stack Overflow. You've gotten a couple downvotes - probably because questions like "why isn't this code working" should include a clear problem definition: what's going wrong, including any errors or erroneous output, along with the minimum complete example of code necessary to reproduce the problem. Check out the how do I write a good question? page and consider editing your question :)

    – MyStackRunnethOver
    Nov 20 '18 at 22:56













  • You probably should include whats going wrong, and where you suspect the error to be

    – Washcloth
    Nov 24 '18 at 0:15














-5












-5








-5








/**
* @param args the command line arguments
*/
public static void main(String args) {
int x;
x= new int [3];
x[0]=4;
x[1]=1;
x[2]=2;
x[3]=3;
x=sortArray (x);
System.out.println (x[2]);
}

public static int indexOfMaxInRange(int A, int i){
int maxIndex=A[0];
while (i < A.length) {
if (A[i]>maxIndex){
maxIndex= A[i];
}
i++;
}
return maxIndex;
}

public static int swapElement (int A,int i1,int i2) {
int i1value=A[i1];
int i2value=A[i2];
A[i1]=A[i2value];
A[i2]=A[i1value];
return A;
}

public static int sortArray (int A) {
for (int i = 0; i < A.length; i++) {
int x=indexOfMaxInRange (A,i);
swapElement (A,x,i);
}
return A;
}


This keeps on returning on with an error.
I can't seem to find what's wrong with my program.
The objective of the program is to sort an array highest from lowest.










share|improve this question
















/**
* @param args the command line arguments
*/
public static void main(String args) {
int x;
x= new int [3];
x[0]=4;
x[1]=1;
x[2]=2;
x[3]=3;
x=sortArray (x);
System.out.println (x[2]);
}

public static int indexOfMaxInRange(int A, int i){
int maxIndex=A[0];
while (i < A.length) {
if (A[i]>maxIndex){
maxIndex= A[i];
}
i++;
}
return maxIndex;
}

public static int swapElement (int A,int i1,int i2) {
int i1value=A[i1];
int i2value=A[i2];
A[i1]=A[i2value];
A[i2]=A[i1value];
return A;
}

public static int sortArray (int A) {
for (int i = 0; i < A.length; i++) {
int x=indexOfMaxInRange (A,i);
swapElement (A,x,i);
}
return A;
}


This keeps on returning on with an error.
I can't seem to find what's wrong with my program.
The objective of the program is to sort an array highest from lowest.







java arrays






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 1:14









GBlodgett

9,55441633




9,55441633










asked Nov 20 '18 at 22:36









American WhaleAmerican Whale

11




11













  • You really should say what the error is, but it looks like an index out of range error in your swapElement method, because you're using the value in the array as the index. Also note your algorithm is O(n^2) because you're iterating from the start of the sequence for every element of the sequence.

    – Elaskanator
    Nov 20 '18 at 22:56








  • 1





    Hi there, welcome to Stack Overflow. You've gotten a couple downvotes - probably because questions like "why isn't this code working" should include a clear problem definition: what's going wrong, including any errors or erroneous output, along with the minimum complete example of code necessary to reproduce the problem. Check out the how do I write a good question? page and consider editing your question :)

    – MyStackRunnethOver
    Nov 20 '18 at 22:56













  • You probably should include whats going wrong, and where you suspect the error to be

    – Washcloth
    Nov 24 '18 at 0:15



















  • You really should say what the error is, but it looks like an index out of range error in your swapElement method, because you're using the value in the array as the index. Also note your algorithm is O(n^2) because you're iterating from the start of the sequence for every element of the sequence.

    – Elaskanator
    Nov 20 '18 at 22:56








  • 1





    Hi there, welcome to Stack Overflow. You've gotten a couple downvotes - probably because questions like "why isn't this code working" should include a clear problem definition: what's going wrong, including any errors or erroneous output, along with the minimum complete example of code necessary to reproduce the problem. Check out the how do I write a good question? page and consider editing your question :)

    – MyStackRunnethOver
    Nov 20 '18 at 22:56













  • You probably should include whats going wrong, and where you suspect the error to be

    – Washcloth
    Nov 24 '18 at 0:15

















You really should say what the error is, but it looks like an index out of range error in your swapElement method, because you're using the value in the array as the index. Also note your algorithm is O(n^2) because you're iterating from the start of the sequence for every element of the sequence.

– Elaskanator
Nov 20 '18 at 22:56







You really should say what the error is, but it looks like an index out of range error in your swapElement method, because you're using the value in the array as the index. Also note your algorithm is O(n^2) because you're iterating from the start of the sequence for every element of the sequence.

– Elaskanator
Nov 20 '18 at 22:56






1




1





Hi there, welcome to Stack Overflow. You've gotten a couple downvotes - probably because questions like "why isn't this code working" should include a clear problem definition: what's going wrong, including any errors or erroneous output, along with the minimum complete example of code necessary to reproduce the problem. Check out the how do I write a good question? page and consider editing your question :)

– MyStackRunnethOver
Nov 20 '18 at 22:56







Hi there, welcome to Stack Overflow. You've gotten a couple downvotes - probably because questions like "why isn't this code working" should include a clear problem definition: what's going wrong, including any errors or erroneous output, along with the minimum complete example of code necessary to reproduce the problem. Check out the how do I write a good question? page and consider editing your question :)

– MyStackRunnethOver
Nov 20 '18 at 22:56















You probably should include whats going wrong, and where you suspect the error to be

– Washcloth
Nov 24 '18 at 0:15





You probably should include whats going wrong, and where you suspect the error to be

– Washcloth
Nov 24 '18 at 0:15












2 Answers
2






active

oldest

votes


















0














Let's start off with x[3] = 3. Since you declared x to be of size 3, your max index would be 2. That was probably your original error, ArrayIndexOutOfBoundsError - which basically means you are trying to assign a value to an index of the array that is not within the range of [0, len(array) - 1]. So, either increase the size of the array or don't assign an element to index 3.



Also, for future reference, letting us know what error you get would be helpful.



When calling functions, try to not have a space between the function name and the opening parenthesis. It will still compile, I believe, but it is weird to read. Also, add spaces around the equals sign. For example:



int x=indexOfMaxInRange (A,i);


should be:



int x = indexOfMaxInRange(A,i);


From what I gather you are implementing selection sort, where you get the max of the whole array, place it as the first element, and find the highest of the array while ignoring the first element and placing that element as the second element in the array. And so on and so forth.



Your swap function looks good as does your sortArray function, however, your indexMaxOfRange function is incorrect. I will leave you to fix that function for yourself, but I will say that indexMaxOfRange is expecting an index to be returned, and at no place in that function are you assigning maxIndex to be an index.






share|improve this answer































    0














    You have several problems with your code. You seem to be confusing elements with index positions. When you have:



    int maxIndex=A[0];
    while (i < A.length) {
    if (A[i]>maxIndex){
    maxIndex= A[i];
    }
    i++;
    }
    return maxIndex;


    You are returning the largest element in the Array, not the index of the largest element of the Array. Then you use this to call



    swapElement (A,x,i);


    (Where x is what is returned by the above method) Which is extremely likely to throw an out of bounds error. Think if the largest element was 1 million. You'd be calling the one millionth index of A



    Also you initialize your Array with a size of 3, and try to put four elements into it. Array index's start at zero, so in an Array of size 3, the last index will be 2.



    You need to change it so that the index, and the element at that index are separate. A simple solution would be to have a separate variable for the element and index. When the element is bigger than the current biggest element, set the index equal to i and the greatest element equal to the new bigger element:



    public static int indexOfMaxInRange(int A, int i){
    int maxIndex = 0;
    int maxElement = 0;
    while(i < A.length) {
    if(A[i]>maxElement){
    maxElement = A[i];
    maxIndex= i;
    }
    i++;
    }
    return maxIndex;
    }


    Lastly in your call:



    swapElement (A,x,i);


    You want to be shifting the greatest element (The element at index x) over, so you need to do swapElement(A,x,i + 1);



    Since you will be swapping one ahead you only need to loop until:



    for(int i = 0; i < A.length-1; i++) 


    When called as:



    int x= new int [4];
    x[0]=4;
    x[1]=1;
    x[2]=2;
    x[3]=3;
    x=sortArray(x);
    System.out.println(Arrays.toString(x));


    It produces the output:



    [1, 2, 3, 4]





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402633%2fsorting-array-from-higest-to-lowest%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Let's start off with x[3] = 3. Since you declared x to be of size 3, your max index would be 2. That was probably your original error, ArrayIndexOutOfBoundsError - which basically means you are trying to assign a value to an index of the array that is not within the range of [0, len(array) - 1]. So, either increase the size of the array or don't assign an element to index 3.



      Also, for future reference, letting us know what error you get would be helpful.



      When calling functions, try to not have a space between the function name and the opening parenthesis. It will still compile, I believe, but it is weird to read. Also, add spaces around the equals sign. For example:



      int x=indexOfMaxInRange (A,i);


      should be:



      int x = indexOfMaxInRange(A,i);


      From what I gather you are implementing selection sort, where you get the max of the whole array, place it as the first element, and find the highest of the array while ignoring the first element and placing that element as the second element in the array. And so on and so forth.



      Your swap function looks good as does your sortArray function, however, your indexMaxOfRange function is incorrect. I will leave you to fix that function for yourself, but I will say that indexMaxOfRange is expecting an index to be returned, and at no place in that function are you assigning maxIndex to be an index.






      share|improve this answer




























        0














        Let's start off with x[3] = 3. Since you declared x to be of size 3, your max index would be 2. That was probably your original error, ArrayIndexOutOfBoundsError - which basically means you are trying to assign a value to an index of the array that is not within the range of [0, len(array) - 1]. So, either increase the size of the array or don't assign an element to index 3.



        Also, for future reference, letting us know what error you get would be helpful.



        When calling functions, try to not have a space between the function name and the opening parenthesis. It will still compile, I believe, but it is weird to read. Also, add spaces around the equals sign. For example:



        int x=indexOfMaxInRange (A,i);


        should be:



        int x = indexOfMaxInRange(A,i);


        From what I gather you are implementing selection sort, where you get the max of the whole array, place it as the first element, and find the highest of the array while ignoring the first element and placing that element as the second element in the array. And so on and so forth.



        Your swap function looks good as does your sortArray function, however, your indexMaxOfRange function is incorrect. I will leave you to fix that function for yourself, but I will say that indexMaxOfRange is expecting an index to be returned, and at no place in that function are you assigning maxIndex to be an index.






        share|improve this answer


























          0












          0








          0







          Let's start off with x[3] = 3. Since you declared x to be of size 3, your max index would be 2. That was probably your original error, ArrayIndexOutOfBoundsError - which basically means you are trying to assign a value to an index of the array that is not within the range of [0, len(array) - 1]. So, either increase the size of the array or don't assign an element to index 3.



          Also, for future reference, letting us know what error you get would be helpful.



          When calling functions, try to not have a space between the function name and the opening parenthesis. It will still compile, I believe, but it is weird to read. Also, add spaces around the equals sign. For example:



          int x=indexOfMaxInRange (A,i);


          should be:



          int x = indexOfMaxInRange(A,i);


          From what I gather you are implementing selection sort, where you get the max of the whole array, place it as the first element, and find the highest of the array while ignoring the first element and placing that element as the second element in the array. And so on and so forth.



          Your swap function looks good as does your sortArray function, however, your indexMaxOfRange function is incorrect. I will leave you to fix that function for yourself, but I will say that indexMaxOfRange is expecting an index to be returned, and at no place in that function are you assigning maxIndex to be an index.






          share|improve this answer













          Let's start off with x[3] = 3. Since you declared x to be of size 3, your max index would be 2. That was probably your original error, ArrayIndexOutOfBoundsError - which basically means you are trying to assign a value to an index of the array that is not within the range of [0, len(array) - 1]. So, either increase the size of the array or don't assign an element to index 3.



          Also, for future reference, letting us know what error you get would be helpful.



          When calling functions, try to not have a space between the function name and the opening parenthesis. It will still compile, I believe, but it is weird to read. Also, add spaces around the equals sign. For example:



          int x=indexOfMaxInRange (A,i);


          should be:



          int x = indexOfMaxInRange(A,i);


          From what I gather you are implementing selection sort, where you get the max of the whole array, place it as the first element, and find the highest of the array while ignoring the first element and placing that element as the second element in the array. And so on and so forth.



          Your swap function looks good as does your sortArray function, however, your indexMaxOfRange function is incorrect. I will leave you to fix that function for yourself, but I will say that indexMaxOfRange is expecting an index to be returned, and at no place in that function are you assigning maxIndex to be an index.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 23:15









          cooljoecooljoe

          113




          113

























              0














              You have several problems with your code. You seem to be confusing elements with index positions. When you have:



              int maxIndex=A[0];
              while (i < A.length) {
              if (A[i]>maxIndex){
              maxIndex= A[i];
              }
              i++;
              }
              return maxIndex;


              You are returning the largest element in the Array, not the index of the largest element of the Array. Then you use this to call



              swapElement (A,x,i);


              (Where x is what is returned by the above method) Which is extremely likely to throw an out of bounds error. Think if the largest element was 1 million. You'd be calling the one millionth index of A



              Also you initialize your Array with a size of 3, and try to put four elements into it. Array index's start at zero, so in an Array of size 3, the last index will be 2.



              You need to change it so that the index, and the element at that index are separate. A simple solution would be to have a separate variable for the element and index. When the element is bigger than the current biggest element, set the index equal to i and the greatest element equal to the new bigger element:



              public static int indexOfMaxInRange(int A, int i){
              int maxIndex = 0;
              int maxElement = 0;
              while(i < A.length) {
              if(A[i]>maxElement){
              maxElement = A[i];
              maxIndex= i;
              }
              i++;
              }
              return maxIndex;
              }


              Lastly in your call:



              swapElement (A,x,i);


              You want to be shifting the greatest element (The element at index x) over, so you need to do swapElement(A,x,i + 1);



              Since you will be swapping one ahead you only need to loop until:



              for(int i = 0; i < A.length-1; i++) 


              When called as:



              int x= new int [4];
              x[0]=4;
              x[1]=1;
              x[2]=2;
              x[3]=3;
              x=sortArray(x);
              System.out.println(Arrays.toString(x));


              It produces the output:



              [1, 2, 3, 4]





              share|improve this answer






























                0














                You have several problems with your code. You seem to be confusing elements with index positions. When you have:



                int maxIndex=A[0];
                while (i < A.length) {
                if (A[i]>maxIndex){
                maxIndex= A[i];
                }
                i++;
                }
                return maxIndex;


                You are returning the largest element in the Array, not the index of the largest element of the Array. Then you use this to call



                swapElement (A,x,i);


                (Where x is what is returned by the above method) Which is extremely likely to throw an out of bounds error. Think if the largest element was 1 million. You'd be calling the one millionth index of A



                Also you initialize your Array with a size of 3, and try to put four elements into it. Array index's start at zero, so in an Array of size 3, the last index will be 2.



                You need to change it so that the index, and the element at that index are separate. A simple solution would be to have a separate variable for the element and index. When the element is bigger than the current biggest element, set the index equal to i and the greatest element equal to the new bigger element:



                public static int indexOfMaxInRange(int A, int i){
                int maxIndex = 0;
                int maxElement = 0;
                while(i < A.length) {
                if(A[i]>maxElement){
                maxElement = A[i];
                maxIndex= i;
                }
                i++;
                }
                return maxIndex;
                }


                Lastly in your call:



                swapElement (A,x,i);


                You want to be shifting the greatest element (The element at index x) over, so you need to do swapElement(A,x,i + 1);



                Since you will be swapping one ahead you only need to loop until:



                for(int i = 0; i < A.length-1; i++) 


                When called as:



                int x= new int [4];
                x[0]=4;
                x[1]=1;
                x[2]=2;
                x[3]=3;
                x=sortArray(x);
                System.out.println(Arrays.toString(x));


                It produces the output:



                [1, 2, 3, 4]





                share|improve this answer




























                  0












                  0








                  0







                  You have several problems with your code. You seem to be confusing elements with index positions. When you have:



                  int maxIndex=A[0];
                  while (i < A.length) {
                  if (A[i]>maxIndex){
                  maxIndex= A[i];
                  }
                  i++;
                  }
                  return maxIndex;


                  You are returning the largest element in the Array, not the index of the largest element of the Array. Then you use this to call



                  swapElement (A,x,i);


                  (Where x is what is returned by the above method) Which is extremely likely to throw an out of bounds error. Think if the largest element was 1 million. You'd be calling the one millionth index of A



                  Also you initialize your Array with a size of 3, and try to put four elements into it. Array index's start at zero, so in an Array of size 3, the last index will be 2.



                  You need to change it so that the index, and the element at that index are separate. A simple solution would be to have a separate variable for the element and index. When the element is bigger than the current biggest element, set the index equal to i and the greatest element equal to the new bigger element:



                  public static int indexOfMaxInRange(int A, int i){
                  int maxIndex = 0;
                  int maxElement = 0;
                  while(i < A.length) {
                  if(A[i]>maxElement){
                  maxElement = A[i];
                  maxIndex= i;
                  }
                  i++;
                  }
                  return maxIndex;
                  }


                  Lastly in your call:



                  swapElement (A,x,i);


                  You want to be shifting the greatest element (The element at index x) over, so you need to do swapElement(A,x,i + 1);



                  Since you will be swapping one ahead you only need to loop until:



                  for(int i = 0; i < A.length-1; i++) 


                  When called as:



                  int x= new int [4];
                  x[0]=4;
                  x[1]=1;
                  x[2]=2;
                  x[3]=3;
                  x=sortArray(x);
                  System.out.println(Arrays.toString(x));


                  It produces the output:



                  [1, 2, 3, 4]





                  share|improve this answer















                  You have several problems with your code. You seem to be confusing elements with index positions. When you have:



                  int maxIndex=A[0];
                  while (i < A.length) {
                  if (A[i]>maxIndex){
                  maxIndex= A[i];
                  }
                  i++;
                  }
                  return maxIndex;


                  You are returning the largest element in the Array, not the index of the largest element of the Array. Then you use this to call



                  swapElement (A,x,i);


                  (Where x is what is returned by the above method) Which is extremely likely to throw an out of bounds error. Think if the largest element was 1 million. You'd be calling the one millionth index of A



                  Also you initialize your Array with a size of 3, and try to put four elements into it. Array index's start at zero, so in an Array of size 3, the last index will be 2.



                  You need to change it so that the index, and the element at that index are separate. A simple solution would be to have a separate variable for the element and index. When the element is bigger than the current biggest element, set the index equal to i and the greatest element equal to the new bigger element:



                  public static int indexOfMaxInRange(int A, int i){
                  int maxIndex = 0;
                  int maxElement = 0;
                  while(i < A.length) {
                  if(A[i]>maxElement){
                  maxElement = A[i];
                  maxIndex= i;
                  }
                  i++;
                  }
                  return maxIndex;
                  }


                  Lastly in your call:



                  swapElement (A,x,i);


                  You want to be shifting the greatest element (The element at index x) over, so you need to do swapElement(A,x,i + 1);



                  Since you will be swapping one ahead you only need to loop until:



                  for(int i = 0; i < A.length-1; i++) 


                  When called as:



                  int x= new int [4];
                  x[0]=4;
                  x[1]=1;
                  x[2]=2;
                  x[3]=3;
                  x=sortArray(x);
                  System.out.println(Arrays.toString(x));


                  It produces the output:



                  [1, 2, 3, 4]






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 21 '18 at 18:15

























                  answered Nov 21 '18 at 1:14









                  GBlodgettGBlodgett

                  9,55441633




                  9,55441633






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402633%2fsorting-array-from-higest-to-lowest%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?