returning the least cost!
<p>Hi
I have written such a code below but it returns wrong output which is not the least value.</p>

<pre><code>    private Element heuristic_Function(List&lt;Element&gt; objectList) {
    System.out.println(objectList.toString());
    Element node =objectList.get(objectList.size() - 1);
    double leastValue = objectList.get(0).getGreedy();
    System.out.println(leastValue);

    for (Element e : objectList) {


        if (leastValue &gt; e.getGreedy()) {


            leastValue = e.getGreedy();
            node = e;
        }

    }
    System.out.println(node.toString());
    System.out.println(leastValue);
    return node;
}
</code></pre>

<p>I send a list to this method several times but it will return wrong output.</p>

<p>output:</p>

<pre><code>[digit:1  greedy2.87 , digit:2 greedy3.67 ,digit:3 greedy3.24 , digit:4  greedy3.67 ] //System.out.println(objectList.toString());
2.87  //System.out.println(leastValue);
digit:4 greedy3.67  //System.out.println(node.toString());
2.87  //System.out.println(leastValue);


[digit:1 greedy2.87 , digit:2  greedy3.67 , digit:3 greedy3.24  , digit:1 greedy3.67 , digit:2  greedy4.47 , digit:3 greedy4.3500000000000005 ] //  System.out.println(objectList.toString());

2.87  //System.out.println(leastValue);
digit:3  greedy4.3500000000000005 //System.out.println(node.toString());
2.87   //System.out.println(leastValue);
</code></pre>

<p>MY question is: why it doesn't return the node which has the least greedy (least value)?
thanks</p>
