04-15-2018 04:14 PM
This VI currently calculates each student's grade and class average based on the exam scores and their weighted percentages. How would I go about ranking each student based on their class average? Would you search the array for the average then sort it? The rank has to correspond to the number of students from the input so starting at 1 and ending with the amount of students in the class.
04-15-2018 05:09 PM
Did you run into a case where you had negative scores? If so, do you REALLY want to make the positive using the absolute value there?
Hit Ctrl+Space and search for sort array.
04-15-2018 06:32 PM
I don't think there will be any negative scores because the lowest is a 0. That function is a round to infinity which ensures that any course average that comes out as a decimal will round up to the nearest integer.
04-15-2018 09:33 PM
The Sort 1D Array works on clusters. It uses the order of the cluster to determine what to look at first. So if you build the cluster with the exam score first, then you can just use the Sort 1D Array.
And from your example, there is no need for the Build Array and the Index Array. Those are just canceling each other out and adding nothing but confusion.
You also might want to move the Round To +Inf to be before the case structure in the data flow. You could run into a weird corner case where the grade will not match the score. Imagine a score of 89.1. The case structure will round it to 89 and give a B while the score will be a 90, which should be an A.
04-16-2018 05:54 AM
Sort Array works on arrays of cluster, but order according to the 1st element. In this case it'd be easy to set the average as 1st element and then sort.
Also, Build Array followed by Index array does ZILTCH! Remove both.
You have a bug/error waiting to happen. You use Round to infinity, but wire the unrounded value to the case, which will perform normal rounding, so if e.g. someone has 89.2 average score, they'll get a B grade, but have 90 as listed score.
/Y
04-16-2018 12:05 PM
Thank you for the help. I've deleted the build array and index array and moved the round to infinity to before the case structure. However, connecting the sort array function to the output cluster of the bundle function gives an error. Would I have to build an array first and then connect it to the sort array? Or use the cluster to array function? Neither seem to be working. Thanks again.
04-16-2018 02:42 PM
@jlc98 wrote:
Would I have to build an array first and then connect it to the sort array?
Yes, you have to build the array first. So put the Sort 1D Array to be AFTER your FOR loop.
04-16-2018 03:06 PM - edited 04-16-2018 04:09 PM
@Yamaeda wrote:
Sort Array works on arrays of cluster, but order according to the 1st element.
Just to expand on this, it actually sorts by all cluster elements, using the cluster order as precedence. (i.e If several array elements have the same value for cluster element 1, it would sort these by cluster element 2, and so on).