블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2307)
Unity3D (564)
Programming (470)
Unreal (4)
Gamebryo (56)
Tip & Tech (182)
협업 (34)
3DS Max (3)
Game (12)
Utility (114)
Etc (92)
Link (31)
Portfolio (19)
Subject (90)
iOS,OSX (37)
Android (12)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (1)
Memories (19)
Interest (37)
Thinking (36)
한글 (26)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (2)
냥이 (9)
육아 (5)
Total1,330,496
Today16
Yesterday334
Statistics Graph

달력

« » 2019.10
    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    

공지사항

태그목록

'sort'에 해당되는 글 3건

  1. 2015.03.04 유니티4.5 Hierarchy 뷰에서 오브젝트 소팅 변경 (2)
  2. 2014.11.21 Sorting Arrays
  3. 2014.09.29 Sort a Custom Class List<T>

Link : http://forum.unity3d.com/threads/unity-4-5-new-hierarchy-window-sorting.248298/#post-1642742


[File]


$AlphaNumericSort.cs





기존의 이름이 아닌 트랜스폼 기준으로 변경되었는데요.


(전 처음에 4.5 버전 버그인줄 알고 당황-_-;)



링크의 글 중간에 보시면

$AlphaNumericsort.cs

파일을 다운 받으시고

프로젝트 폴더/Assets/Editor/ 

에 넣어주세요.

유니티를 다시 띄우면 그림처럼 아이콘이 하나가 추가됩니다.

이 아이콘을 누르시면 소팅 방식을 트랜스폼 혹은 이름으로 변경 가능해집니다.




출처 : http://www.gamecodi.com/board/zboard.php?id=GAMECODI_Talkdev&page=1&sn1=&divpage=1&sn=on&ss=on&sc=on&keyword=sort&select_arrange=headnum&desc=asc&no=2703

Posted by blueasa

댓글을 달아 주세요

  1. 2015.03.05 09:47 신고 배고픈멍멍이  댓글주소  수정/삭제  댓글쓰기

    좋은 글 감사합니다 ㅎ~

Sorting Arrays

Programming/C# / 2014.11.21 11:53

Sorting Arrays [C#]

This example shows how to sort arrays in C#. Array can be sorted using static method Array.Sortwhich internally use Quicksort algorithm.

Sorting array of primitive types

To sort array of primitive types such as intdouble or string use method Array.Sort(Array) with the array as a paramater. The primitive types implements interface IComparable, which is internally used by the Sort method (it calls IComparable.Com­pareTo method). See example how to sort int array:

[C#]

// sort int array
int[] intArray = new int[5] { 8, 10, 2, 6, 3 };
Array.Sort(intArray);
// write array
foreach (int i in intArray) Console.Write(i + " ");  // output: 2 3 6 8 10

or how to sort string array:

[C#]

// sort string array
string[] stringArray = new string[5] { "X", "B", "Z", "Y", "A" };
Array.Sort(stringArray);
// write array
foreach (string str in stringArray) Console.Write(str + " "); // output: A B X Y Z

Sorting array of custom type using delegate

To sort your own types or to sort by more sophisticated rules, you can use delegate to anonymous method. The generic delegate Comparison<T> is declared as public delegate int Comparison<T> (T x, T y). It points to a method that compares two objects of the same type. It should return less then 0 when X < Y, zero when X = Y and greater then 0 when X > Y. The method (to which the delegate points) can be also an anonymous method (written inline).

Following example demonstrates how to sort an array of custom type using the delegate to anonynous comparison method. The custom type in this case is a class User with properties Name and Age.

[C#]

// array of custom type
User[] users = new User[3] { new User("Betty", 23),  // name, age
                             new User("Susan", 20),
                             new User("Lisa", 25) };

[C#]

// sort array by name
Array.Sort(users, delegate(User user1, User user2) {
                    return user1.Name.CompareTo(user2.Name);
                  });
// write array (output: Betty23 Lisa25 Susan20)
foreach (User user in users) Console.Write(user.Name + user.Age + " ");

[C#]

// sort array by age
Array.Sort(users, delegate(User user1, User user2) {
                    return user1.Age.CompareTo(user2.Age); // (user1.Age - user2.Age)
                  });
// write array (output: Susan20 Betty23 Lisa25)
foreach (User user in users) Console.Write(user.Name + user.Age + " ");

Sorting array using IComparable

If you implement IComparable interface in your custom type, you can sort array easily like in the case of primitive types. The Sort method calls internally IComparable.Com­pareTo method.

[C#]

// custom type
public class User : IComparable
{
  // ...

  // implement IComparable interface
  public int CompareTo(object obj)
  {
    if (obj is User) {
      return this.Name.CompareTo((obj as User).Name);  // compare user names
    }
    throw new ArgumentException("Object is not a User");
  }
}

Use it as you sorted the primitive types in the previous examples.

[C#]

// sort using IComparable implemented by User class
Array.Sort(users);  // sort array of User objects



출처 : http://www.csharp-examples.net/sort-array/

Posted by blueasa
TAG array, sort

댓글을 달아 주세요

List<cTag> week = new List<cTag>();
// add some stuff to the list
// now sort
week.Sort(delegate(cTag c1, cTag c2) { return c1.date.CompareTo(c2.age); });



참조 : http://stackoverflow.com/questions/3163922/sort-a-custom-class-listt

Posted by blueasa
TAG custom, list, sort

댓글을 달아 주세요