You are viewing a single comment's thread. Return to all comments →
import math import os import random import re import sys def sort_array(arr,k): for i in range(len(arr)-1): for j in range(len(arr)-1-i): current = arr[j] nexts = arr[j+1] checkcurr = arr[j][k] checknex = arr[j+1][k] if checkcurr > checknex: arr[j] = nexts arr[j+1] = current print_array(arr) def print_array(arr): for i in range(len(arr)): print(*arr[i],sep=" ") if __name__ == '__main__': nm = input().split() n = int(nm[0]) m = int(nm[1]) arr = [] for _ in range(n): arr.append(list(map(int, input().rstrip().split()))) k = int(input()) sort_array(arr,k)
Seems like cookies are disabled on this browser, please enable them to open this website
Athlete Sort
You are viewing a single comment's thread. Return to all comments →