---

 src/ls.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --quilt old/src/ls.c new/src/ls.c
--- old/src/ls.c
+++ new/src/ls.c
@@ -2759,6 +2759,17 @@ is_directory (const struct fileinfo *f)
   return f->filetype == directory || f->filetype == arg_directory;
 }
 
+/* Return true if F is a symlink that refers to a directory.  */
+static bool
+is_symlink_to_directory (const struct fileinfo *f)
+{
+  return (f->filetype == symbolic_link
+          && f->linkname
+          && f->linkok
+          && f->stat_ok
+          && S_ISDIR (f->linkmode));
+}
+
 /* Put the name of the file that FILENAME is a symbolic link to
    into the LINKNAME field of `f'.  COMMAND_LINE_ARG indicates whether
    FILENAME is a command-line argument.  */
@@ -2904,8 +2915,10 @@ typedef int (*qsortFunc)(V a, V b);
 #define DIRFIRST_CHECK(a, b)						\
   do									\
     {									\
-      bool a_is_dir = is_directory ((struct fileinfo const *) a);	\
-      bool b_is_dir = is_directory ((struct fileinfo const *) b);	\
+      bool a_is_dir = is_directory ((struct fileinfo const *) a)	\
+	|| is_symlink_to_directory ((struct fileinfo const *) a);	\
+      bool b_is_dir = is_directory ((struct fileinfo const *) b)	\
+	|| is_symlink_to_directory ((struct fileinfo const *) b);	\
       if (a_is_dir && !b_is_dir)					\
 	return -1;         /* a goes before b */			\
       if (!a_is_dir && b_is_dir)					\
