3
data = {{1, 2}, {2, 2}, {3, 3}};  
MinimalBy[data, Norm@# &]  
Output: {{2, 2}}  

When applying numerically :

data = {{1, 2}, {2, 2}, {3, 3}};  
MinimalBy[data, N@Norm@# &]  
Output: {{1, 2}} 
lesobrod
  • 1,657
  • 9
  • 14
  • 1
    Notice that, as mentioned in Details section of document of MinimalBy: Values of $f[e_i]$ are compared using the same canonical order as in Sort. – xzczd Mar 11 '24 at 10:13
  • See also https://mathematica.stackexchange.com/a/78183/1871 and https://mathematica.stackexchange.com/q/31261/1871 – xzczd Mar 11 '24 at 10:19

2 Answers2

5

TakeSmallestBy gives the correct solution automatically

TakeSmallestBy[data, Norm, 1]

{{1, 2}}

A hash-free MinimalBy solution

MinimalBy[data, N @* Norm]

{{1, 2}}

Documentation Details of TakeSmallestBy

"TakeSmallestBy sorts ... by numerical magnitude."

Documentation Details of MinimalBy

"Values ... are compared using the same canonical order as in Sort."

Norm /@ data // Sort

{2 * Sqrt[2], 3 * Sqrt[2], Sqrt[5]}

N[%]

{2.82843, 4.24264, 2.23607}

eldo
  • 67,911
  • 5
  • 60
  • 168
4

Norm doesn't give the correct answer (see @Nasser's answer).

workaround

data = {{1, 2}, {2, 2}, {3, 3}};
MinimalBy[data, ( # . # &)]
(*{{1, 2}}*)
Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55