Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering bug in renderer #570

Closed
cmontella opened this issue Nov 17, 2016 · 2 comments
Closed

Ordering bug in renderer #570

cmontella opened this issue Nov 17, 2016 · 2 comments
Assignees

Comments

@cmontella
Copy link
Contributor

Sort students alphabetically by grade (some test data is committed below)

search
  [#student name grade teacher]
  index = sort[value: name, per: grade]
  
bind @browser
  [#div grade children: 
    [#h3 sort: 0, text: "Grade: {{grade}}"]
    [#div sort: index, text: "{{index}} {{name}}"]]

The output is:

1 Damion

### Grade: 12

2 Gretchen
3 Octavio
4 Pa

The expected output is:


### Grade: 12

1 Damion
2 Gretchen
3 Octavio
4 Pa

Despite being told it's sort: 0, the h3 is ordered at position 2 in the div. If I change it's sort: -1, then it appears in the right spot.


Commit some test data

commit
  [#student name: "Damion", grade: 12, teacher: "Mrs. Purple", GPA: "3.8"]
  [#student name: "Gretchen", grade: 12, teacher: "Mrs. Yellow", GPA: "2.8"]
  [#student name: "Octavio", grade: 12, teacher: "Mrs. Purple", GPA: "3.4"]
  [#student name: "Pa", grade: 12, teacher: "Mrs. Yellow", GPA: "3.5"]
@pingram3541
Copy link

pingram3541 commented Nov 18, 2016

Interesting, an index value of 0, 1, or 2 on the h3 tag all result in the rendered indexed position of 2.

When I read the docs about sort it details that indexing begins at a positive int so wouldn't an index value of 0 or even -1 for that matter be invalid? Also, since the H3 tag has an auto-index value less than that of the div tags, one would expect it to render first?

This seems to do the trick =)

search
  [#student name grade teacher]
  index = sort[value: name, per: grade]

bind @browser
  [#div grade children: 
    [#h3 sort: 1, text: "Grade: {{grade}}"]
    [#div sort: index + 1, text: "{{index}} {{name}}"]]

@joshuafcole
Copy link
Contributor

I'm pretty sure this is an off-by-one (the renderer was written long before
we switched to 1-indexed, and I don't recall if it's been updated). Will
investigate.

On Thu, Nov 17, 2016 at 7:01 PM pingram3541 notifications@github.com
wrote:

Interesting, an index value of 0, 1, or 2 all result in the indexed
position of 2.

When I read the docs about sort
http://docs.witheve.com/handbook/general/sort/ it details that indexing
begins at a positive int so wouldn't an index value of 0 or even -1 for
that matter be invalid? Also, since the H3 tag has an auto-index value less
than that of the div tags, one would expect it to render first?


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#570 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AATKDm4S8vhGXfOVFFyc8uhGT1CFrxt1ks5q_RT7gaJpZM4K17IV
.

@joshuafcole joshuafcole assigned ibdknox and unassigned joshuafcole Nov 21, 2016
ibdknox added a commit that referenced this issue Nov 22, 2016
Signed-off-by: Chris Granger <ibdknox@gmail.com>
ibdknox added a commit that referenced this issue Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants