# Sort Stocks by MarketCap

If I correctly understand, here I have all the existing companies listed in every market and identified by each real name:

assets = FinancialData["Stocks"];
names = FinancialData[assets, "Name"];


How could I order the element of names vector within an other vector where elements are ordered by "MarketCap" property of FinancialData?

names = FinancialData[{"GE", "GOOGL", "MSFT", "AAPL", "HPQ"}, "Name"];
mcaps = FinancialData[{"GE", "GOOGL", "MSFT", "AAPL", "HPQ"}, "MarketCap"];

sortednames = names[[Ordering[mcaps]]]

{"HP Inc", "General Electric Co", "Alphabet Inc", "Apple Inc", "Microsoft Corp"}


Alternatively, you can construct a list of name and market cap pairs and sort by the second column:

sortednamesmcaps = SortBy[Last] @
FinancialData[{"GE", "GOOGL", "MSFT", "AAPL", "HPQ"}, {"Name",  "MarketCap"}]

Grid @ sortednamesmcaps


• Thank you kglr, the second solution was exactly what I was looking for! Any ideas why it doesn't work with this? sortednamesmcaps = SortBy[Last] @ FinancialData["Stocks", {"Name", "MarketCap"}][[;;100]]; Grid @ sortednamesmcaps Doesn't any company has MarketCap property? My final goal would be from all stocks select those whose MarketCap value is Greater than a fixed value..
– Nate
Apr 25 '20 at 16:12