Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
var obj = [{
    name: "Vi jay",  
    age: 20,
    marks : {s1:50,s2:60,s3:30,s4:70,s5:80,s6:45,s7:34};
},  {
     name: "ram",
    age: 20,
    marks : {s1:50,s2:60,s3:45,s4:70,s5:20,s6:45,s7:34};
},  {
     name: "jay",
    age: 20 ,
    marks : {s1:23,s2:30,s3:46,s4:70,s5:80,s6:45,s7:56};
},  {
     name: "kamlesh",
    age: 20,
    marks : {s1:46, s2:60, s3:78, s4:70, s5:30, s6:20, s7:34};
},   {
     name: "nitis",
    age: 20,
    marks : {s1:56, s2:35,s3:30,s4:20,s5:67,s6:45,s7:34};
},   {
     name: "Prant",
    age: 20,
    marks : {s1:78,s2:60,s3:68,s4:70,s5:34,s6:45,s7:89};
},  {
     name: "anu",
  age: 20,
    marks : {s1:89,s2:60,s3:30,s4:23,s5:56,s6:70,s7:34};
},  {
     name: "neeraj",
    age: 20,
    marks : {s1:50,s2:70,s3:30,s4:90,s5:80,s6:30,s7:34};
},  {
     name: "arti",
    age:20,
    marks : {s1:78,s2:45,s3:30,s4:78,s5:37,s6:45,s7:34};
}];

Can anyone suggest to fetch top 5 students with Name according to marks with subject .? I can sort array object but problem in fetching top 5 students.

share|improve this question
1  
Welcome to Stack Overflow! You seem to be asking for someone to write some code for you. Stack Overflow is a question and answer site, not a code-writing service. Please see here to learn how to write effective questions. – Daniel Corzo Jan 10 at 13:56
    
what is a top student? what have you tried? where is your sorting part? – Nina Scholz Jan 10 at 14:14
    
Just I want fetch top 5 student name like vijay , neeraj, prant, kamlesh, arti . according to subject marks like s1, s2, s3, s4, s5, s6, s7 . – Vijay Pal Jan 10 at 14:22
    
You could first make a new property with total marks of each person and then sort the array by total marks, descending. Then take the top 5 items for the list. – Nina Scholz Jan 10 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.