def solution(data, ext, val_ext, sort_by):
result = []
indexDict = {
"code": 0,
"date": 1,
"maximum": 2,
"remain": 3
}
for currentData in data:
extIdx = indexDict[ext]
if(currentData[extIdx] < val_ext):
result.append(currentData)
return sorted(result, key=lambda x: x[indexDict[sort_by]])