creating a rank list by sorting an array

Hi,

I have two arrays where one array represents a collection of names and the other describes their associated marks.I wanted to sort the marks inside the array in ascending order, and then also the respective names related to the marks.

My aim is to create a rank list.

    float sum = 0;

    String [] name = {"A", "B", "C", "D","E"};
    float [] mark = {12, 2, 4, 6, 23};

    void setup() {

      size(600, 600);
      smooth();
    }

    void draw() {
      background(225);
      fill(0);
      println(name.length); 
      for (int i =0; i<name.length; i++) {
        text(name[i] + ":"+ mark[i], 100, 100+i*50);
      }
    }

//// i wanted to sort it as E:23, A:12, D:6, C:4, B:2

It would be great if someone can help me with this. :)

Many thanks in advance, Yousuf

Answers

Sign In or Register to comment.