Convert Python function to Powershell script

I have some code written in Python which I cannot rewrite in Powershell, this task is very difficult to me, maybe because Python is very abstract for me.

Code in Python:

from itertools import count 
  
def longest_word(lst, K): 
    cnt = count() 
    return sorted(lst, key = lambda w : (len(w), next(cnt)), reverse = True)(:K)

——————————————————————————————-

Maybe you already guessed what I want to implement?

Problem: Write a Powershell script to get 10 longest words chart.

But what I was able to implement find longest word (not words) in Powershell:

$File | foreach {
    $Line = $_
    $Line.Split(" .,:;?!/()(){}-```"") | foreach {
        $Word = $_.ToUpper()
        If ($Word(0) -ge 'A' -and $Word(0) -le "Z") {           
            If ($Word.Length -gt $Longest.Length) { $Longest = $Word }
        }
    } 
}

Please help and thank You in advance.