Click here to Skip to main content
15,908,013 members
Home / Discussions / C#
   

C#

 
GeneralRe: Updating of datagrid is not happening Pin
Member 1144944716-Dec-15 0:25
Member 1144944716-Dec-15 0:25 
Questionhow can i get Array sort index? Pin
smallkubi15-Dec-15 0:06
smallkubi15-Dec-15 0:06 
AnswerRe: how can i get Array sort index? Pin
OriginalGriff15-Dec-15 1:09
mveOriginalGriff15-Dec-15 1:09 
AnswerRe: how can i get Array sort index? Pin
harold aptroot15-Dec-15 1:49
harold aptroot15-Dec-15 1:49 
GeneralRe: how can i get Array sort index? Pin
smallkubi15-Dec-15 2:48
smallkubi15-Dec-15 2:48 
GeneralRe: how can i get Array sort index? Pin
harold aptroot15-Dec-15 3:19
harold aptroot15-Dec-15 3:19 
GeneralRe: how can i get Array sort index? Pin
smallkubi15-Dec-15 4:16
smallkubi15-Dec-15 4:16 
AnswerRe: how can i get Array sort index? Pin
BillWoodruff15-Dec-15 4:52
professionalBillWoodruff15-Dec-15 4:52 
A little Linq, perhaps:
C#
int[] iary = new[] { 5, 4, 1, 3, 2 };
var sorted = iary.OrderBy(itm1 => itm1).ToArray();
var unsortedIndexes = sorted.Select(itm2 => Array.IndexOf(iary, itm2, 0)).ToArray();
Note that using 'OrderBy creates a copy of the Array.
C#
>? sorted
{int[5]}
    [0]: 1
    [1]: 2
    [2]: 3
    [3]: 4
    [4]: 5

> ? unsortedIndexes
{int[5]}
    [0]: 2
    [1]: 4
    [2]: 3
    [3]: 1
    [4]: 0

> ? iary // after creating 'sorted using 'OrderBy
{int[5]}
    [0]: 5
    [1]: 4
    [2]: 1
    [3]: 3
    [4]: 2

«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin


modified 15-Dec-15 11:23am.

Questionhow to improve paint() speed? Pin
smallkubi14-Dec-15 19:26
smallkubi14-Dec-15 19:26 
AnswerRe: how to improve paint() speed? Pin
BillWoodruff14-Dec-15 21:44
professionalBillWoodruff14-Dec-15 21:44 
GeneralRe: how to improve paint() speed? Pin
smallkubi15-Dec-15 0:03
smallkubi15-Dec-15 0:03 
Questionc# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 5:27
Member 1182236414-Dec-15 5:27 
AnswerRe: c# problem with combobox in form opened in panel Pin
Simon_Whale14-Dec-15 5:37
Simon_Whale14-Dec-15 5:37 
GeneralRe: c# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 5:47
Member 1182236414-Dec-15 5:47 
GeneralRe: c# problem with combobox in form opened in panel Pin
Simon_Whale14-Dec-15 5:51
Simon_Whale14-Dec-15 5:51 
GeneralRe: c# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 5:56
Member 1182236414-Dec-15 5:56 
GeneralRe: c# problem with combobox in form opened in panel Pin
Simon_Whale14-Dec-15 5:57
Simon_Whale14-Dec-15 5:57 
GeneralRe: c# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 6:04
Member 1182236414-Dec-15 6:04 
GeneralRe: c# problem with combobox in form opened in panel Pin
Eddy Vluggen14-Dec-15 6:13
professionalEddy Vluggen14-Dec-15 6:13 
GeneralRe: c# problem with combobox in form opened in panel Pin
Simon_Whale14-Dec-15 6:16
Simon_Whale14-Dec-15 6:16 
GeneralRe: c# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 6:25
Member 1182236414-Dec-15 6:25 
GeneralRe: c# problem with combobox in form opened in panel Pin
Simon_Whale14-Dec-15 6:27
Simon_Whale14-Dec-15 6:27 
GeneralRe: c# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 6:32
Member 1182236414-Dec-15 6:32 
GeneralRe: c# problem with combobox in form opened in panel Pin
Member 1182236414-Dec-15 6:29
Member 1182236414-Dec-15 6:29 
AnswerRe: c# problem with combobox in form opened in panel Pin
BillWoodruff14-Dec-15 7:28
professionalBillWoodruff14-Dec-15 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.