import os import lmdb os.chdir(os.path.dirname(os.path.abspath(__file__))) db = lmdb.open("db", subdir=True, map_size=1048576 * 2) items = [] with db.begin() as txn: cursor = txn.cursor() for key, value in cursor: if value != b'': key_str = key.decode('utf-8') value_str = value.decode('utf-8') int_part_str = value_str.split('p')[1].split('.')[0] int_part = int(int_part_str) items.append((key_str, int_part)) sorted_items = sorted(items, key=lambda item: item[1]) for key, int_value in sorted_items: print(f"{key} {int_value}", end=' ') print()