Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from copy import deepcopy
- def func():
- filename = 'test.txt'
- strok1 = '8 7 9 5 90'
- strok2 = '2 4 5 7 9 0'
- with open(filename, 'w') as of:
- of.write('{}\n{}\n'.format(strok1, strok2))
- t_array = np.empty(0)
- with open(filename, 'r') as i_f:
- for line in i_f:
- t = line.split('\n')
- if len(t) > 0 and len(t[0]) > 0:
- t_array = np.append(t_array, np.asarray(t[0].split(' '), np.int))
- t_array[::-1].sort()
- array_desc = deepcopy(t_array)
- t_array.sort()
- array_asc = deepcopy(t_array)
- print('Array in desc order: -->\n{}\nArray in asc order: -->\n{}\n'.format(array_desc, array_asc))
- if __name__ == "__main__":
- func()
Advertisement
Add Comment
Please, Sign In to add comment