반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- hive
- GIT
- PostgreSQL
- Python
- Google Excel
- Apache
- 파이썬
- PANDAS
- c#
- Redshift
- gas
- Github
- Excel
- dataframe
- Java
- matplotlib
- django
- Kotlin
- Presto
- Tkinter
- array
- SQL
- math
- Google Spreadsheet
- google apps script
- list
- numpy
- string
- PySpark
Archives
- Today
- Total
달나라 노트
C# : Sort (array 정렬하기) 본문
728x90
반응형
Sort method는 Array를 정렬해줍니다.
using System;
class MyProgram
{
static void Main()
{
string[] test_arr = { "Pineapple", "Banana", "Apple", "Grape" };
Array.Sort(test_arr);
foreach (string t in test_arr)
{
Console.WriteLine(t);
}
}
}
-- Result
Apple
Banana
Grape
Pineapple
test_arr은 무작위로 array 속 요소들이 존재합니다.
여기에 Array.Sort를 적용하면 test_arr 속 요소들이 알파벳 기준 오름차순으로 정렬됩니다.
using System;
class MyProgram
{
static void Main()
{
int[] test_arr = { 5, 2, 7, 8, 3 };
Array.Sort(test_arr);
foreach (int t in test_arr)
{
Console.WriteLine(t);
}
}
}
-- Result
2
3
5
7
8
숫자로 된 array에도 적용할 수 있습니다.
728x90
반응형
'C# > C#' 카테고리의 다른 글
| C# : field와 property (get, set, Access Modifier) (0) | 2022.03.23 |
|---|---|
| C# : 생성자(Constructor) (0) | 2022.03.23 |
| C# : class와 object (class, 객체, Access Modifier) (0) | 2022.03.23 |
| C# : method (0) | 2022.03.23 |
| C# : Array Max, Min, Sum, Average (Array의 최대값, 최소값, 합, 평균 얻기) (0) | 2022.03.23 |
Comments
