p
File size: 666 Bytes
0820d3a
 
 
 
 
82901f0
0820d3a
134abb3
 
0820d3a
134abb3
 
 
82901f0
 
 
 
 
 
 
134abb3
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()