0

I have a list of random numbers. In each row there 5 numbers. I want to find the minimum value of the first column and extract the row where the minimum value placed there. How can I do it using Mathematica?

For example, consider the following code:

ClearAll["Global`*"];
list = Table[  {RandomInteger[{0, 20}], RandomInteger[{0, 20}],   RandomInteger[{0, 20}], RandomInteger[{0, 20}],    RandomInteger[{0, 20}]}  , {i, 1, 20}  ]

It gave me

Out[75]= {{20, 14, 7, 11, 15}, {20, 5, 11, 9, 20}, {9, 20, 15, 10,   17}, {18, 6, 19, 7, 2}, {1, 15, 10, 16, 6}, {16, 4, 13, 0, 4}, {15,  7, 9, 19, 13}, {16, 16, 1, 12, 6}, {6, 1, 15, 18, 14}, {5, 17, 17,  15, 8}, {2, 3, 19, 13, 16}, {3, 0, 1, 4, 4}, {2, 13, 1, 15, 16}, {5,  18, 16, 8, 17}, {11, 15, 14, 5, 18}, {0, 0, 16, 12, 16}, {8, 7, 0,  14, 20}, {16, 8, 15, 0, 2}, {20, 5, 12, 19, 9}, {6, 19, 18, 11, 15}}

I want a code which gives me

{{1, 15, 10, 16, 6}}

where the minimum value of the first column is 1 and the extract the row where the minimum value (1) exists there. How can I do that?

AYBRXQD
  • 1,085
  • 6
  • 16

1 Answers1

1

Try this:

list = RandomInteger[{0, 20}, {20, 5}];
result = MinimalBy[list, First]
Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309