java - Alphabetically sorting array in sync with another array -


i'm working on simple program that, now, writes inputted names , marks 2 separate arrays, array counters synchronised. example, name in entry #3 on first array corresponds marks in entry #3 on second array. code this:

import java.io.*;  public class project {     int ctr;     int ctr1;     int pos;     int temp;     int max;      public static void main(string args[]) throws ioexception     {         new project().input();     }      void input() throws ioexception     {         bufferedreader obj = new bufferedreader(new inputstreamreader(system.in));         system.out.println ("how many children?");         int n = integer.parseint(obj.readline());         string a[] = new string[n];         int b[] = new int[n];         for(ctr=0;ctr<n;ctr++)         {             system.out.println("enter name");             a[ctr]=obj.readline();             system.out.println("enter marks");             b[ctr]=integer.parseint(obj.readline());         }     } } 

i want alphabetically sort list of names, when array printed in order, names alphabetically arranged z.

what's best way sort string array alphabetically without using functions compareto() or sort(), rather bubble or exchange sorting using nested loops?

how can synchronise sorting, names shuffled in first array, corresponding marks shuffled identically, keeping data correct?

first, advise against doing @ all. make class holding name , mark, store in array, , sort resulting array.

then, if want that, in bubble sort example, when normal code says exchange elements , j in array sorting, exchange elements , j in other array. job.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -