# Sorting by power

I want to sort this table by column "d" such that Mathematica should also take the exponential values into account. Can somebody help me here?

• Welcome to Mathematica StackExchange! Please edit your question and include all relevant information, including your table and any Mathematica code you are using. Mar 28, 2023 at 14:03
• The input is: Partition[Flatten[fitteddata], Length[fitteddata[[1]]]] // TableForm and I want to keep the first row.
– Miss
Mar 28, 2023 at 14:14
• No, it's not possible as it's an output of many input files. I just want to know if there is a trick to sorting such Flatten table.
– Miss
Mar 28, 2023 at 14:23
• @Miss, evaluate Partition[Flatten[fitteddata], Length[fitteddata[[1]]]] (without TableForm!) , and paste the ouput in your question. Mar 28, 2023 at 14:32
• Welcome to the Mathematica Stack Exchange. You can learn to ask better questions by visiting the site's Help page. Thanks.
– Syed
Mar 28, 2023 at 16:16

it's not possible as it's an output of many input files

This makes it little harder, but here is an example.

The idea is to use SortBy[data, #[[5]] &]  this sorts the whole data using 5th column as key . Make sure not to use TableForm when sorting as it is a wrapper. Do the SortBy on the row data before adding the tittle row and before adding TableForm to it.

title = {"phiA(deg)", "z0", "w", "l", "d", "dnm", "ξ", "ζ"}
data = {{33, 50, 0.00008, 0.01, 1.0*10^(-8), 4.8*10^(-9), 1, 1},
{24.3, 50, 0.00008, 0.01, 1.1*10^(-8), 4.8*10^(-9), 1, 1},
{38, 50, 0.00008, 0.01, 1.2*10^(-8), 4.8*10^(-9), 1, 1},
{30, 50, 0.00008, 0.01, 1.3*10^(-8), 4.8*10^(-9), 1, 1},
{22, 50, 0.00008, 0.01, 0.9*10^(-8), 4.8*10^(-9), 1, 1},
{35, 50, 0.00008, 0.01, 0.8*10^(-8), 4.8*10^(-9), 1, 1},
{30, 50, 0.00008, 0.01, 1.5*10^(-8), 4.8*10^(-9), 1, 1}
}


Now sort the data (without the title row) then add the title row next

dataSorted = SortBy[data, #[[5]] &] (*sort on 5th column*)
({title}~Join~dataSorted) // TableForm