{"action":"opened","issue":{"url":"https://api.github.com/repos/SharedMocha/Java/issues/86","repository_url":"https://api.github.com/repos/SharedMocha/Java","labels_url":"https://api.github.com/repos/SharedMocha/Java/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/SharedMocha/Java/issues/86/comments","events_url":"https://api.github.com/repos/SharedMocha/Java/issues/86/events","html_url":"https://github.com/SharedMocha/Java/issues/86","id":363762150,"node_id":"MDU6SXNzdWUzNjM3NjIxNTA=","number":86,"title":"Priority Queue - Sort by HEIGHT (High to low)","user":{"login":"SharedMocha","id":7443342,"node_id":"MDQ6VXNlcjc0NDMzNDI=","avatar_url":"https://avatars2.githubusercontent.com/u/7443342?v=4","gravatar_id":"","url":"https://api.github.com/users/SharedMocha","html_url":"https://github.com/SharedMocha","followers_url":"https://api.github.com/users/SharedMocha/followers","following_url":"https://api.github.com/users/SharedMocha/following{/other_user}","gists_url":"https://api.github.com/users/SharedMocha/gists{/gist_id}","starred_url":"https://api.github.com/users/SharedMocha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SharedMocha/subscriptions","organizations_url":"https://api.github.com/users/SharedMocha/orgs","repos_url":"https://api.github.com/users/SharedMocha/repos","events_url":"https://api.github.com/users/SharedMocha/events{/privacy}","received_events_url":"https://api.github.com/users/SharedMocha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-25T20:54:21Z","updated_at":"2018-09-25T20:54:21Z","closed_at":null,"author_association":"OWNER","body":"//VVIMP\r\n//**Comparator** (this is used to display list is ascending or descending order)\r\n//**Comparable** (this is to sort the array using a key like height,weight,age)\r\n\r\nimport java.util.*;\r\npublic class HelloWorld{\r\n\r\n\r\n     public static void main(String []args){\r\n         PQS pqs = new PQS();\r\n    PriorityQueue<Height> temp = new PriorityQueue<>(5,pqs); \r\n         Height hs1 =new Height(\"Hemanth\",10);\r\n         Height hs2 =new Height(\"Divya\",70);\r\n         Height hs3 =new Height(\"Suman\",50);\r\n         Height hs4 =new Height(\"Lila\",400);\r\n         Height hs5 =new Height(\"Prompt\",-50);\r\n\r\n        temp.add(hs1);\r\n        temp.add(hs2);\r\n                temp.add(hs3);\r\n                        temp.add(hs4);\r\n                                temp.add(hs5);\r\n          \r\n          while(!temp.isEmpty()){\r\n              System.out.println(temp.poll());\r\n          }                      \r\n     }\r\n}\r\n\r\nclass Height implements Comparable<Height>{\r\n    String name;\r\n    Integer  height;\r\n    \r\n    public Height(String name,Integer height){\r\n        this.name = name;\r\n        this.height = height;\r\n    }\r\n    \r\n    String getName(){\r\n        return name;\r\n    }\r\n    \r\n    Integer  getHeight(){\r\n        \r\n        return height;\r\n    }\r\n    \r\n    \r\n    @Override\r\n    public String toString(){\r\n        return \"The person is\"+getName()+\"-->\"+getHeight();\r\n    }\r\n    \r\n    @Override\r\n    public int compareTo(Height theOtherPersonsHeight){\r\n        int value = this.height.compareTo(theOtherPersonsHeight.height);\r\n        return value;\r\n    }\r\n\r\n    \r\n    \r\n}\r\nclass PQS implements Comparator<Height>{\r\n@Override\r\n         public int compare(Height one,Height two){\r\n             //System.out.println(one + \"  \"+ two);\r\n             //return one.height-two.height;\r\n             return two.height-one.height;\r\n         }\r\n         \r\n     }\r\n\r\n         "}}
{"actor":{"display_login":"SharedMocha"}}