Lambda function Python3 no change in output
<pre><code>def salary_sort(thing):
    def importantparts(thing):
        for i in range(1, len(thing)):
            a=thing[i].split(':')
            output = (a[1],a[0],a[8])
            sortedlist = sorted(output, key = lambda item: item[2], reverse=True)
            print(sortedlist)
    return importantparts(thing)

salary_sort(employee_data)
</code></pre>

<p>This function is supposed to sort out a list of names by their salary. 
I managed to isolate the first last names and salaries but I can't seem to get it to sort by their salaries </p>

<p>'Thing' aka employee_data</p>

<pre><code>employee_data = ["FName  LName   Tel      Address  City   State  Zip   Birthdate   Salary",
"Arthur:Putie:923-835-8745:23 Wimp Lane:Kensington:DL:38758:8/31/1969:126000",
"Barbara:Kertz:385-573-8326:832 Ponce  Drive:Gary:IN:83756:12/1/1946:268500",
"Betty:Boop:245-836-8357:635 Cutesy Lane:Hollywood:CA:91464:6/23/1923:14500",.... etc.]
</code></pre>

<p>Output</p>

<pre><code>['Putie', 'Arthur', '126000']
['Kertz', 'Barbara', '268500']
['Betty', 'Boop', '14500']
['Hardy', 'Ephram', '56700']
['Fardbarkle', 'Fred', '780900']
['Igor', 'Chevsky', '23400']
['James', 'Ikeda', '45000']
['Cowan', 'Jennifer', '58900']
['Jesse', 'Neal', '500']
['Jon', 'DeLoach', '85100']
['Jose', 'Santiago', '95600']
['Karen', 'Evich', '58200']
['Lesley', 'Kirstin', '52600']
['Gortz', 'Lori', '35200']
['Corder', 'Norma', '245700']
</code></pre>

<p>The problem is that you sort <strong>individual</strong> elements (meaning <code>['Putie', 'Arthur', '126000']</code>), based on the salary value, and not the whole array.</p>

<p>Also, since you want to sort the salaries, you have to cast them to <code>int</code>, otherwise alphabetical sort is going to be used.</p>

<p>You can take a look at the following :</p>

<pre><code>def salary_sort(thing):
    def importantparts(thing):

        data = []

        for i in range(1, len(thing)):
            a=thing[i].split(':')
            output = (a[1],a[0],int(a[8]))
            data.append(output)

        data.sort(key=lambda item: item[2], reverse=True)
        return data

    return importantparts(thing)

employee_data = ["FName  LName   Tel      Address  City   State  Zip   Birthdate   Salary", \
"Arthur:Putie:923-835-8745:23 Wimp Lane:Kensington:DL:38758:8/31/1969:126000", \
"Barbara:Kertz:385-573-8326:832 Ponce  Drive:Gary:IN:83756:12/1/1946:268500", \
"Betty:Boop:245-836-8357:635 Cutesy Lane:Hollywood:CA:91464:6/23/1923:14500"]

print(salary_sort(employee_data))
</code></pre>

<p>Which gives, as expected :</p>

<pre><code>[('Kertz', 'Barbara', 268500), ('Putie', 'Arthur', 126000), ('Boop', 'Betty', 14500)]
</code></pre>

<p>What I did there is pushing all the relevant data for the employees into a new array (named <code>data</code>), and then sorted this array using the <code>lambda</code> function.</p>

python sorting lambda