Advertisement
moinularif

sort

Oct 14th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.UI;
  5.  
  6. public class DataListController : MonoBehaviour {
  7.  
  8.    
  9.     public List<string> universityName = new List<string>();
  10.     public List<int> points = new List<int>();
  11.  
  12.     bool swapped = true;
  13.     // Use this for initialization
  14.     void Start()
  15.     {
  16.         //sortTheList();
  17.     }
  18.    
  19.     // Update is called once per frame
  20.     void Update ()
  21.     {
  22.        // sortTheList();
  23.        
  24.     }
  25.  
  26.     void sortTheList()
  27.     {
  28.  
  29.         while (swapped)
  30.         {
  31.             swapped = false;
  32.             for (int i = 0; i <= universityName.Count; i++)
  33.             {
  34.                 if (points[i] < points[i + 1])
  35.                 {
  36.                     int tmp = points[i];
  37.                     points[i] = points[i + 1];
  38.                     points[i + 1] = tmp;
  39.  
  40.                     string tmpName = universityName[i];
  41.                     universityName[i] = universityName[i + 1];
  42.                     universityName[i + 1] = tmpName;
  43.  
  44.                 }
  45.  
  46.                 swapped = true;
  47.             }
  48.  
  49.             if (!swapped)
  50.                 break;
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement