<p>You are given two positive integers <code>n</code> and <code>k</code>. A factor of an integer <code>n</code> is defined as an integer <code>i</code> where <code>n % i == 0</code>.</p> <p>Consider a list of all factors of <code>n</code> sorted in <strong>ascending order</strong>, return <em>the </em><code>k<sup>th</sup></code><em> factor</em> in this list or return <code>-1</code> if <code>n</code> has less than <code>k</code> factors.</p> <p> </p> <p><strong>Example 1:</strong></p> <pre> <strong>Input:</strong> n = 12, k = 3 <strong>Output:</strong> 3 <strong>Explanation:</strong> Factors list is [1, 2, 3, 4, 6, 12], the 3<sup>rd</sup> factor is 3. </pre> <p><strong>Example 2:</strong></p> <pre> <strong>Input:</strong> n = 7, k = 2 <strong>Output:</strong> 7 <strong>Explanation:</strong> Factors list is [1, 7], the 2<sup>nd</sup> factor is 7. </pre> <p><strong>Example 3:</strong></p> <pre> <strong>Input:</strong> n = 4, k = 4 <strong>Output:</strong> -1 <strong>Explanation:</strong> Factors list is [1, 2, 4], there is only 3 factors. We should return -1. </pre> <p> </p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= k <= n <= 1000</code></li> </ul>