I would like to sort the securities by highest momemtums in a specific window length( for example 3 days)

close = history of close price for securities for past 3 days

factor = close[-1] / close[0]

and then sort securities by this factor.

after that select top n security + bottom n security for long short strategy

Can you help me achieve this?