Sep-22-2022, 02:55 AM
Sorry I am a novice.
I am trying to sort a custom dictionary consisting of a list of 2-element lists, (lexical entry and definition), using sort() and/or sorted() with sorting keys.
I need to sort using keys both for i) list position (i.e., position 0), and ii) normal alphabetic (case-insensitive) order as used for standard dictionaries.
I know how to each of these things alone, but not both at once, and this does not seem to be a problem of 'successive sorts', but different parameters of one sort. So I am using 'key=str.lower' for normal alphabetic sort, and
'key= itemgetter(0) for sorting on first element.
Perhaps this would be easier with a different data structure?
Thanks!
I am trying to sort a custom dictionary consisting of a list of 2-element lists, (lexical entry and definition), using sort() and/or sorted() with sorting keys.
I need to sort using keys both for i) list position (i.e., position 0), and ii) normal alphabetic (case-insensitive) order as used for standard dictionaries.
I know how to each of these things alone, but not both at once, and this does not seem to be a problem of 'successive sorts', but different parameters of one sort. So I am using 'key=str.lower' for normal alphabetic sort, and
'key= itemgetter(0) for sorting on first element.
Perhaps this would be easier with a different data structure?
Thanks!