<s> __author__ = "<STR_LIT>" <EOL> def merge_sort ( array ) : <EOL> '''<STR_LIT>''' <EOL> if len ( array ) < <NUM_LIT:2> : <EOL> return array <EOL> mid = len ( array ) // <NUM_LIT:2> <EOL> left = merge_sort ( array [ : mid ] ) <EOL> right = merge_sort ( array [ mid : ] ) <EOL> res = [ ] <EOL> i , j = <NUM_LIT:0> , <NUM_LIT:0> <EOL> while i < len ( left ) and j < len ( right ) : <EOL> if left [ i ] <= right [ j ] : <EOL> res . append ( left [ i ] ) <EOL> i += <NUM_LIT:1> <EOL> else : <EOL> res . append ( right [ j ] ) <EOL> j += <NUM_LIT:1> <EOL> if left [ i : ] : <EOL> res . extend ( left [ i : ] ) <EOL> if right [ j : ] : <EOL> res . extend ( right [ j : ] ) <EOL> return res <EOL> '''<STR_LIT>''' <EOL> def merge_files ( list_files ) : <EOL> result = [ ] <EOL> final = [ ] <EOL> for filename in list_files : <EOL> aux = [ ] <EOL> with open ( filename , '<STR_LIT:r>' ) as file : <EOL> for line in file : <EOL> aux . append ( int ( line ) ) <EOL> result . append ( aux ) <EOL> final . extend ( result . pop ( ) ) <EOL> for l in result : <EOL> final = merge ( l , final ) <EOL> return final <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import doctest <EOL> doctest . testmod ( ) </s>
