だから私は、現在持っていることは、誰もがそれが何であるかを知っていれば、私はKWICの反復を作ってるんだ、このように見える文字列、リストのタプルのリストをソートします。大文字小文字を区別しない
hello here, hello there, hello Everywhere
です。必要な書式は、リストのタプルのリストです。大文字と小文字は区別されません。だから、最後に、私は現在、私は
Final_Array.sort(key = lambda a: a[0][0].lower())
のようなPythonのソートを使用していますしかし、それは私に
(['Everywhere', 'hello', 'here,', 'hello', 'there,', 'hello'], 0)
(['hello', 'there,', 'hello', 'Everywhere', 'hello', 'here,'], 0)
(['hello', 'Everywhere', 'hello', 'here,', 'hello', 'there,'], 0)
(['hello', 'here,', 'hello', 'there,', 'hello', 'Everywhere'], 0)
(['here,', 'hello', 'there,', 'hello', 'Everywhere', 'hello'], 0)
(['there,', 'hello', 'Everywhere', 'hello', 'here,', 'hello'], 0)`
のように見えるソートされたリストを与える
(['here,', 'hello', 'there,', 'hello', 'Everywhere', 'hello'], 0)
(['hello', 'there,', 'hello', 'Everywhere', 'hello', 'here,'], 0)
(['there,', 'hello', 'Everywhere', 'hello', 'here,', 'hello'], 0)
(['hello', 'Everywhere', 'hello', 'here,', 'hello', 'there,'], 0)
(['Everywhere', 'hello', 'here,', 'hello', 'there,', 'hello'], 0)
(['hello', 'here,', 'hello', 'there,', 'hello', 'Everywhere'], 0)`
のように見えるソートされていないリストを持っています
明らかに、hello Everywhere
は、hello here
と一緒にhello there
の前でなければなりません。 アクセスされたリストの最初の単語を下位に送信することに基づいてソートしていますが、並べ替えてアクセスしたリストのすべてのエントリを比較する必要があります。次に、すべてを無視しながら。
:-)その意見に同意し、すべての単語を下げる必要があります。 'lambda a:list(map(str.lower、 a [0])) ' –
素晴らしい!本当にありがとう、私は永遠にそれに固執しています。 – Dringo