File size: 358 Bytes
01bc423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import json
import tyro

def main(data_dir:str, out_file:str) -> None:

    with open(data_dir, "r") as f:
        data = json.load(f)

    sorted_data = sorted(data, key=lambda x: len(x['conversations'][0]['value']), reverse=True)

    with open(out_file, "w") as f:
        json.dump(sorted_data, f, indent=4)

if __name__ == "__main__":
    tyro.cli(main)