Sort elements of an array in ascending order

后端 未结 5 1897
陌清茗
陌清茗 2020-12-18 12:26

I\'m trying to sort an array in ascending order. For some reason it only performs the for loop once. Why doesn\'t it keep going until everything is sorted?

It\'s for

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 13:18

    This will sort an array in ascending order

    int arr[]={33,3,4,5,1};
    Arrays.sort(arr);
    System.out.println(Arrays.toString (arr));
    

    output will:-[1,3,4,5,33]

提交回复
热议问题