How to sort the numbers using c#

Posted by karthik on Stack Overflow See other posts from Stack Overflow or by karthik
Published on 2010-04-20T07:44:56Z Indexed on 2010/04/20 7:53 UTC
Read the original article Hit count: 220

Filed under:

I need some help in code to be able to handle the following logic.

The program gets many input in Integers like 10,16,3,17,21,29,6

Logic to be done :

scenario : 1

First select the biggest 4 numbers of input which is 16,17,21,29 Now assign the values to A,B,C and D

A = smallest in the selected 4

B = biggest in the selected 4

C = second smallest in the selected 4

D = third smallest in the selected 4

Result to be Displayed :

A = 16

B = 29

C = 17

D = 21

scenario : 2

If the user gives 3 inputs like 3,6,10 assign only to A,B,C and should ignore D

Result to be Displayed :

A = 3

B = 10

C = 6

© Stack Overflow or respective owner

Related posts about c#