class Solution: """ @param A: an integer array @return: nothing """ def sortIntegers(self, A): new_list = list(A) list_len = len(new_list) for i in range(list_len): for j in range(i+1,list_len): if new_list[i]>new_list[j]: new_list[i],new_list[j] = new_list[j],new_list[i] return new_list if __name__ == "__main__": test_input = eval(input("請輸入數組:")) so = Solution() print(so.sortIntegers(test_input))
測試結果數組