1
考虑以下结构如何通过key进行排序,然后通过嵌套值
'source-document01013.txt': {'AAAGCTTACA': {'endPos': '141',
'startPos': '132'},
'AAATCTTAGA': {'endPos': '105',
'startPos': '96'},
'AAATGTCCCC': {'endPos': '75',
'startPos': '66'}
}
我想通过'source-document01013.txt'
,然后由startPos来排序的话,我怎么能去吗?
我以前在下面的行,但现在我添加了一个嵌套的字典,并打破了。
newDict = sorted(dictionary.items(), key = lambda x: (x[1], int(x[1]['startPos'])))
错误:IndexError: tuple index out of range
邮你有人可以帮助你的错误 – mvelay