# What is the closest star to Earth other than the sun?

How to find the Sun's nearest neighbor star using Mathematica? I tried

but it didn't work

-

a=Most@Sort[StarData[
EntityClass["Star", "StarNearest10"], {"Name",
"DistanceFromSun"}], #1[[2]] < #2[[2]] &]

(*{{"Proxima Centauri",   Quantity[4.2181,  "LightYears"]},
{"Rigel Kentaurus A",  Quantity[4.38982, "LightYears"]},
{"Rigel Kentaurus B",  Quantity[4.4001,  "LightYears"]},
{"Barnard's Star",     Quantity[5.9339,  "LightYears"]},
{"Wolf 359",           Quantity[7.78813, "LightYears"]},
{"Lalande 21185",      Quantity[8.30217, "LightYears"]},
{"Luyten 726-8 B",     Quantity[8.5573,  "LightYears"]},
{"Luyten 726-8 A",     Quantity[8.5573,  "LightYears"]},
{"Sirius",             Quantity[8.59093, "LightYears"]}*)

TimelinePlot[
Association[(a[[#, 1]] -> a[[#, 2]]) & /@ Range@Length@a],
DateFunction -> (DatePlus[DateObject[Round[#*365*24*60*60, 1]],
Quantity[-1900, "year"]] &), FrameLabel -> "Light Years",
PlotLabel -> "Distance from Sun"]

-
Nice alternative use of TimelinePlot! – 2012rcampion Mar 21 at 3:51
Or using SortBy: a = Rest@SortBy[StarData[EntityClass["Star", "StarNearest10"], {"Name", "DistanceFromSun"}], Last] – Bob Hanlon Mar 21 at 4:09
Clever use of DateFunction. Is this the best idiom to make a timeline-like graphic whose axis is not time? – ConvexMartian Mar 26 at 13:49